我想将固定行值与不同的列值组合起来,但跳过空白单元格。我有代码,但不起作用。请提出建议
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