Dave Punky
Board Regular
- Joined
- Jan 7, 2010
- Messages
- 133
Hi all,
I have an idea how to do this, but I've not been having much luck.
Basically what I have is a long string with each section split by a tab. Here is some sample data to explain what I mean:
Basically what I need to do is extract each 3rd section (code section) from each line and take that data, then loop and take the 3rd section from the next line down.
I don't want to put the data into a worksheet (which is why I'm not using Excels import data function) as I'm then going to take that data and complete an action, then loop it and start again.
So using the data above, I basically want to extract the data like so:
I was thinking of using Split to split the whole string (as each section being split by a tab I can set this as the split condition) but the problem I have is trying to work a loop to cycle through the whole split variant, and how to determine when the end of the loop is also.
The end of each line is also separated by an enter character so I'm not sure if it would be better to split each line first and then take the data or just by splitting by tabs?
I'm not sure if I've explained this very well, but hopefully somebody can point me in the right direction!
I have an idea how to do this, but I've not been having much luck.
Basically what I have is a long string with each section split by a tab. Here is some sample data to explain what I mean:
Code:
Ref: 2Ref: Code: Date: Address:
1000000, 21111111 0123,456789, 01/09/2011, MR X., Address Line 1, Address Line 2, Zip Code
1000001, 21116111 0123,785412, 01/09/2011, MR Y., Address Line 1, Address Line 2, Zip Code
1000002, 21221452 0123,874114, 01/09/2011, MR Z., Address Line 1, Address Line 2, Zip Code
Basically what I need to do is extract each 3rd section (code section) from each line and take that data, then loop and take the 3rd section from the next line down.
I don't want to put the data into a worksheet (which is why I'm not using Excels import data function) as I'm then going to take that data and complete an action, then loop it and start again.
So using the data above, I basically want to extract the data like so:
Code:
Dim refcode as string
Dim alldata as variant
alldata = split(Table Of Data, vbTab)
Do while X <= Last Array Entry in alldata
refcode = 0123,456789, (then 0123,785412, and then 0123,874114,)
call action(refcode)
X = X+1
Loop
I was thinking of using Split to split the whole string (as each section being split by a tab I can set this as the split condition) but the problem I have is trying to work a loop to cycle through the whole split variant, and how to determine when the end of the loop is also.
The end of each line is also separated by an enter character so I'm not sure if it would be better to split each line first and then take the data or just by splitting by tabs?
I'm not sure if I've explained this very well, but hopefully somebody can point me in the right direction!