Forum Discussion
Shanike De Silva
Oct 16, 2018Copper Contributor
If next column is blank move to next function
Hi, I'm using the following code to convert the attached range into numbers format. I'm using the text to column function to do so. Columns("A:A").Select Selection.TextToColumns Destinatio...
BobOrrell
Oct 16, 2018Iron Contributor
Sure, that's exactly what Do / Loop is for. You just have to make the references dynamic. This should run through every column until the top cell of the column is blank.
Dim i As Integer
i = 1
Do While Cells(1, i).Value <> ""
Columns(i).Select
Selection.TextToColumns Destination:=Cells(1, i), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
:=Array(1, 1), TrailingMinusNumbers:=True
i = i + 1
Loop