Hello all!
I was wondering if someone here could help me out with a VBA problem:
I'm trying to parse a piece of data, say ( 12.3 13.0 5.5). Ideally, I'd like to "split" it and have the following data:
number(0) = 12.3
number(1) = 13.0
number(2) = 5.5
My problem is that my "number" array contains spaces (" ") which makes it impossible to parse my data into the correct cells. Due to significant figures, I can never account for the spaces. Can anyone help? It would be much appreciated!
Thanks,
sC
Welcome to the forum.
Where does the string come from?
What do you have so far?
Microsoft MVP - Excel
Entia non sunt multiplicanda sine necessitate
Something like this is the data to be split is in a variable.
Sub z() Dim vntNumbers As Variant Dim strData As String Dim lngIndex As Long strData = " 12.3 13.0 5.5 " Do While InStr(1, strData, Space(2), vbTextCompare) > 0 strData = Replace(strData, Space(2), Space(1)) Loop vntNumbers = Split(Trim(strData), Space(1)) For lngIndex = LBound(vntNumbers) To UBound(vntNumbers) Debug.Print lngIndex, vntNumbers(lngIndex) Next End Sub
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks