Split function problems
Hi CG Rosén
Not sure about your labels, which need to exist in sufficient named + number
qty, but maybe you need to adapt like this
Sub test()
Dim sStr As String
Dim i As Long, j As Long
Dim v
sStr = "* *x* * * *yyyy*1* **2*"
v = Split(sStr, "*")
j = 0
For i = LBound(v) To UBound(v)
If Len(v(i)) Then
If Len(Trim(v(i))) Then
j = j + 1
Debug.Print j, i, v(i)
End If
End If
'Me("Label" & (j)).Caption = v(i)
Next i
End Sub
Ctrl-g to see the Immediate window
Regards,
Peter T
"CG Rosén" wrote in message
...
Hi Group,
Stuck with below problem. The code seems to work
but something is missing. The array seems to increase
with 1 value for every time the code is run. Any hints
of to solve this is welcomed
Brgds
CG Rosén
Worksheets("Sheet1").Cells(1, 1) is of type "* *x* * * *yyyy*1* **2*"
the letters and numbers occurs in different length and positions.
sStr = Worksheets("Sheet1").Cells(1, 1)
v = Split(sStr, "*")
j = 0
For i = LBound(v) To UBound(v)
j = j + 1
Me("Label" & (j)).Caption = v(i)
Next i
|