![如何用 VBA 有条件地连接某个范围?](https://linux22.com/image/1631520/%E5%A6%82%E4%BD%95%E7%94%A8%20VBA%20%E6%9C%89%E6%9D%A1%E4%BB%B6%E5%9C%B0%E8%BF%9E%E6%8E%A5%E6%9F%90%E4%B8%AA%E8%8C%83%E5%9B%B4%EF%BC%9F.png)
答案1
像这样吗?
debug.print 将会把每次循环的结果打印到开发人员的即时窗口中。
Sub MyConcat()
Dim RefExc As String
Dim c As Range
Dim x As Long
For Each c In Sheet1.Range("L2:L10")
If c.Value = -2 Then
For x = 6 To 73
If x <> 71 Then RefExc = RefExc & ", " & Sheet1.Cells(c.Row, x)
Next x
Debug.Print RefExc
End If
Next c
End Sub