I am trying to copy the contents of an array [sNames] into another one [sNames2], but only if the element is NOT EQUAL to " ".
My current code is:
====================================
Dim i, j As Integer
j = 0
For i = LBound(sNames) To UBound(sNames)
If sNames(i) <> " " Then
sNames2(j) = sNames(i)
j = j + 1
End If
Next i
====================================
But I'm getting an error:
Run-time error '9':
Subscript out of range
I know there must be a simple fix, but I'm not sure what I'm doing wrong.
Any suggestions?
My current code is:
====================================
Dim i, j As Integer
j = 0
For i = LBound(sNames) To UBound(sNames)
If sNames(i) <> " " Then
sNames2(j) = sNames(i)
j = j + 1
End If
Next i
====================================
But I'm getting an error:
Run-time error '9':
Subscript out of range
I know there must be a simple fix, but I'm not sure what I'm doing wrong.
Any suggestions?