Anthony
Anthony

Reputation: 923

removing the nulls from an array and copying to new array

I am splitting a line of text into an array then attempting to put into a new array without the null spaces. For some reason it's not copying from the old array into the new one. BTW if someone has a more efficient way of doing this I am open to that as well.

Dim x As Variant, i As Integer, m As String, rdate As String, k(0 To 50) As Variant, j As Integer
rdate = ThisWorkbook.Sheets("sheet1").Range("a58").Value
j = 0
x = Split(rdate, "  ")

For i = 0 To UBound(x)
    If x(i) <> "" Then
        k(j) = x(i)
        j = j + 1
        m = m & j & k(j) & vbCrLf
    End If
Next
MsgBox m

Upvotes: 1

Views: 195

Answers (1)

helios
helios

Reputation: 13841

Your script is adding k(j) AFTER incrementing j... your msgbox appears empty.

Upvotes: 1

Related Questions