我想將固定行值與不同的列值組合起來,但跳過空白單元格。我有一個代碼,但它不起作用。請建議
Public Function SuperJoin(r1 As Range, r2 As Range, IgnoreBlanks As Boolean) As String
Dim i As Long, j As Long
Dim s As String
j = r2.Cells.Count
For i = 1 To j
If IgnoreBlanks = True Then
If r2.Cells(i) = True Then
If r2.Cells(i).Value <> "" Then s = s & "-" & r2.Cells(i)
End If
Else
If r2.Cells(i) = True Then
s = s & "-" & r2.Cells(i)
End If
End If
Next
i = r1.Count
For j = 1 To i
SuperJoin = SuperJoin & "----" & r1(1, j) & r2(1, j)
Next j
SuperJoin = Mid(SuperJoin, 5)
End Function