I am doing Text to Columns on an unknown number of columns. Columns 1-11 are always "general", but columns 12 and higher need to be text. So far the max number has been 22 columns. Making the max number some large number seems inefficient.
Is there a way to count the max number of columns before Text to Column conversion and reflect that number in the array?
You don't know what you don't know...
Is there a way to count the max number of columns before Text to Column conversion and reflect that number in the array?
Code:
Sub Text2Columns()
Dim textArray(0 To 21) As Variant
Dim i As Long
For i = 0 To 11
textArray(i) = Array(i + 1, 1)
Next i
For i = 12 To 21
textArray(i) = Array(i + 1, 2)
Next i
objWB.Worksheets(1).columns("A:A").TextToColumns DataType:=xlDelimited, Tab:=False, Semicolon:=False, _
Comma:=False, Space:=False, Other:=True, OtherChar:="|", _
FieldInfo:=textArray, TrailingMinusNumbers:=True
End Sub
You don't know what you don't know...