E
Excel Monkey
The following routine is not working when I expand the variable h. I have
tried changing these to String variable and I get the same error (Run-Time 9
Subscript ouf of Range). Why is this?
Sub Test()
Dim M As Double
Dim h As Variant
Dim k As Variant
h = "4:4,3:3" '< this works but will not if "4:4,3:3,2:2"
If Not UBound(Split(h, ",")) = 0 Then
For M = 0 To UBound(Split(h, ","))
If M = 0 Then
k = k & Split(Split(h, ",")(M), ":")(M)
Else
k = k & ", " & Split(Split(h, ",")(M), ":")(M)
End If
Next
h = k
End If
End Sub
Thanks
EM
tried changing these to String variable and I get the same error (Run-Time 9
Subscript ouf of Range). Why is this?
Sub Test()
Dim M As Double
Dim h As Variant
Dim k As Variant
h = "4:4,3:3" '< this works but will not if "4:4,3:3,2:2"
If Not UBound(Split(h, ",")) = 0 Then
For M = 0 To UBound(Split(h, ","))
If M = 0 Then
k = k & Split(Split(h, ",")(M), ":")(M)
Else
k = k & ", " & Split(Split(h, ",")(M), ":")(M)
End If
Next
h = k
End If
End Sub
Thanks
EM