Hi Everyone,
I was hoping you could help me solve a problem. I'm trying to make a macro that will turn a fixed length text file into columns. So I Googled around and found this piece of code that works:
Sub MySplit()
Columns(1).TextToColumns Destination:=Range("A1"), DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 1), Array(4, 1), Array(12, 1), Array(19, 1), _
Array(24, 1))
End Sub
I want to take it a step further. Often times, I know the position of where to split beforehand. So rather than having to manually type that it in every time, I want excel to pass an array of position values into the text to columns splitter. Is this possible? I imagine it would look something like this.
Sub MySplit()
myArray = range("R65:R125") 'My list of position values
Columns(1).TextToColumns Destination:=range("A1"), DataType:=xlFixedWidth, FieldInfo:=myArray()
End Sub
I've been trying for the last two hours, and it's been driving me crazy
Any help would be greatly appreciated.
Bookmarks