I'm trying to create a VBScript that performs a TextToColumns, while looping, starting with a column far to the right that moves its way left until reaches Column B:B. An example below of the type of data I'm working with. I'd prefer they stay together as with the examples below.
Also, the 4th code is a bonus, I WILL need to eventually sum all the columns up once they're broken, so if you could assist me with that as well, I would greatly appreciate it.
Thanks for taking time to help out!
Also, the 4th code is a bonus, I WILL need to eventually sum all the columns up once they're broken, so if you could assist me with that as well, I would greatly appreciate it.
Thanks for taking time to help out!
Code:
I'd like to turn this.
Int Dec 1 Dec 2 Dec 3 Dec 4 Dec 5 Dec 6 Dec 7
0000
0030
0100
0130
0200
0230
0300
0330
0400 0/3 0/3 0/2 0/2 0/2 0/2 0/2
0430 0/3 0/3 0/2 0/2 0/2 0/2 0/2
0500 0/3 0/3 0/2 0/2 0/2 0/2 0/2
0530 0/3 0/3 0/2 0/2 0/2 1/2 0/2
0600 0/3 0/3 0/2 0/2 0/2 0/2 0/2
0630 0/3 0/3 0/2 0/2 0/2 0/2 0/2
0700 0/3 0/3 0/2 0/2 1/2 0/2 0/2
0730 1/3 0/3 0/2 0/2 0/2 0/2 0/2
0800 0/3 0/3 0/2 0/2 0/2 0/2 2/2
0830 0/3 0/3 0/2 1/2 0/2 0/2 0/2
0900 0/3 0/3 1/2 1/2 0/2 1/2 1/2
0930 1/3 0/3 0/2 1/2 0/2 0/2 0/2
1000 0/3 0/3 0/2 1/2 0/2 1/2 0/2
1030 0/3 1/3 1/2 0/2 1/2 0/2 1/2
1100 1/3 2/3 1/2 0/2 0/2 2/2 1/2
1130 1/3 2/3 1/2 0/2 1/2 0/2 0/2
1200 1/3 1/3 0/2 0/2 0/2 1/2 1/2
1230 1/3 0/3 0/2 0/2 2/2 0/2 2/2
1300 1/3 0/3 0/2 0/2 2/2 1/2 2/2
1330 1/3 0/3 0/2 0/2 2/2 2/2 1/2
1400 1/3 0/3 0/2 1/2 2/2 2/2 2/2
1430 2/3 0/3 1/2 0/2 2/2 2/2 2/2
1500 2/3 0/3 2/2 1/2 2/2 2/2 2/2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0 3 0 3 0 2 1 2 0 2 1 2 0 2
1030 0 3 1 3 1 2 0 2 1 2 0 2 1 2
1100 1 3 2 3 1 2 0 2 0 2 2 2 1 2
1130 1 3 2 3 1 2 0 2 1 2 0 2 0 2
1200 1 3 1 3 0 2 0 2 0 2 1 2 1 2
1230 1 3 0 3 0 2 0 2 2 2 0 2 2 2
1300 1 3 0 3 0 2 0 2 2 2 1 2 2 2
1330 1 3 0 3 0 2 0 2 2 2 2 2 1 2
1400 1 3 0 3 0 2 1 2 2 2 2 2 2 2
1430 2 3 0 3 1 2 0 2 2 2 2 2 2 2
1500 2 3 0 3 2 2 1 2 2 2 2 2 2 2
1530 2 3 0 3 2 2 1 2 2 2 2 2 2 2
1600 2 3 2 3 3 3 0 2 2 2 2 2 2 2
1630 2 3 0 3 2 3 1 2 2 2 2 2 2 2
1700 1 3 1 3 2 3 2 2 2 2 2 2 2 2
1730 0 3 0 3 1 3 1 2 1 2 2 2 2 2
1800 0 3 1 3 0 3 2 2 1 2 2 2 2 2
1830 1 3 0 3 0 3 2 2 0 2 2 2 0 2
1900 0 3 0 3 0 3 2 2 0 2 2 2 2 2
1930 0 3 0 3 0 3 0 2 0 2 2 2 1 2
2000 0 3 0 3 0 3 0 2 0 2 0 2 1 2
2030 0 3 0 3 0 3 0 2 0 2 0 2 0 2
2100 0 3 0 3 0 3 1 2 0 2 1 2 1 2
2130 0 3 0 3 0 3 0 2 0 2 0 2 1 2
2200 0 3 0 3 0 3 0 2 0 2 0 2 2 2
2230 2 3 0 3 0 3 0 2 0 2 2 2 2 2
2300 1 3 0 3 0 3 0 2 0 2 0 2 0 2
2330 0 3 0 3 0 3 0 2 0 2 0 2 0 2
Int Dec 1 Dec 2 Dec 3 Dec 4 Dec 5 Dec 6 Dec 7
Code:
Sub TextToColumns()
Dim Col As Range
Dim Row As Range
Sheets("TestSheet").Select
Range("H:H").Select
Set Col = Selection
Set Row = Selection
Selection.TextToColumns _
Destination:=Cells(Col.Row, Col.Column), _
DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=True, _
Space:=True, _
Tab:=True, _
Semicolon:=False, _
Comma:=False, _
Space:=True, _
Other:=True, OtherChar:="/"
ActiveCell.EntireColumn.Insert
End Sub
Code:
Bonus!
Int Dec 1 Dec 2 Dec 3 Dec 4 Dec 5 Dec 6 Dec 7
0000
0030
0100
0130
0200
0230
0300
0330
0400 0 3 0 3 0 2 0 2 0 2 0 2 0 2
0430 0 3 0 3 0 2 0 2 0 2 0 2 0 2
0500 0 3 0 3 0 2 0 2 0 2 0 2 0 2
0530 0 3 0 3 0 2 0 2 0 2 1 2 0 2
0600 0 3 0 3 0 2 0 2 0 2 0 2 0 2
0630 0 3 0 3 0 2 0 2 0 2 0 2 0 2
0700 0 3 0 3 0 2 0 2 1 2 0 2 0 2
0730 1 3 0 3 0 2 0 2 0 2 0 2 0 2
0800 0 3 0 3 0 2 0 2 0 2 0 2 2 2
0830 0 3 0 3 0 2 1 2 0 2 0 2 0 2
0900 0 3 0 3 1 2 1 2 0 2 1 2 1 2
0930 1 3 0 3 0 2 1 2 0 2 0 2 0 2
1000 0 3 0 3 0 2 1 2 0 2 1 2 0 2
1030 0 3 1 3 1 2 0 2 1 2 0 2 1 2
1100 1 3 2 3 1 2 0 2 0 2 2 2 1 2
1130 1 3 2 3 1 2 0 2 1 2 0 2 0 2
1200 1 3 1 3 0 2 0 2 0 2 1 2 1 2
1230 1 3 0 3 0 2 0 2 2 2 0 2 2 2
1300 1 3 0 3 0 2 0 2 2 2 1 2 2 2
1330 1 3 0 3 0 2 0 2 2 2 2 2 1 2
1400 1 3 0 3 0 2 1 2 2 2 2 2 2 2
1430 2 3 0 3 1 2 0 2 2 2 2 2 2 2
1500 2 3 0 3 2 2 1 2 2 2 2 2 2 2
1530 2 3 0 3 2 2 1 2 2 2 2 2 2 2
1600 2 3 2 3 3 3 0 2 2 2 2 2 2 2
1630 2 3 0 3 2 3 1 2 2 2 2 2 2 2
1700 1 3 1 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