How can I execute this function using VBA in excel?
Solution 1:
I found IsNumeric(B)
to be true for blank cells,
so I changed your If
statement accordingly. This worked for me:
If IsNumeric(B) And B <> "" Then
Cells(B.Row, 9) = Cells(B.Row + 1, 8) & Cells(B.Row + 2, 8)
Cells(B.Row + 1, 8) = ""
Cells(B.Row + 2, 8) = ""
End If
If B.Row > 9 Then Exit For
Obviously 8
and 9
are the column numbers for H
and I
, respectively.
I added the
If B.Row > 9 Then Exit For
line because I had a problem with the loop not terminating; if
For Each B In ClientTable.Columns(2).Cells
works for you, you can take out the If B.Row > 9 Then Exit For
.