Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.setup
|
|||
|
|||
![]()
I have a text file that I want to import into excel. However the file is
formatted in a strange way: Key Name Customer ADVANCED ADVANCED LTD 20 TRADING ESTATE WILL ROAD WORTS WEST SUS BU11 8OP Telephone : 01103 221111 Fax : 01103 444449 Category : P Quality : T Acc Code : A33 ALWIN ALWIN CO LTD ELL ROAD BROMLAND WEST SUS B70 0DW Telephone : 0111 117 1234 Fax : 0111 511 9111 Category : S Quality : T Acc Code : A48 and this goes on for 1600 lines. I have recorded the following macro to move the records into each column and to then delete the gap left behind so that looks like: KEYNAME NAME ADD1 ADD2 ADD3 ADD4 PCODE TEL FAX CAT QUAL ACC xxxxxxxxx xxxxxx xxxx xxxxx xxxxx xxxxx xxxxxx xxx xxx xxx xxxxx xxxx xxxxxxxxx xxxxxx xxxx xxxxx xxxxx xxxxx xxxxxx xxx xxx xxx xxxxx xxxx Here is the macro: Range("B3").Select Selection.Cut Destination:=Range("C2") Range("B4").Select Selection.Cut Destination:=Range("D2") Range("B5").Select Selection.Cut Destination:=Range("E2") Range("E2").Select ActiveWindow.SmallScroll ToRight:=1 Range("B6").Select Selection.Cut Destination:=Range("F2") Range("B7").Select Selection.Cut Destination:=Range("G2") Range("G2").Select ActiveWindow.ScrollColumn = 3 ActiveWindow.ScrollColumn = 2 ActiveWindow.ScrollColumn = 1 Range("B8").Select Selection.Cut Destination:=Range("H2") Range("H2").Select ActiveWindow.ScrollColumn = 4 ActiveWindow.ScrollColumn = 3 ActiveWindow.ScrollColumn = 2 ActiveWindow.ScrollColumn = 1 Range("B9").Select Selection.Cut Destination:=Range("I2") Range("I2").Select ActiveWindow.ScrollColumn = 5 ActiveWindow.ScrollColumn = 4 ActiveWindow.ScrollColumn = 3 ActiveWindow.ScrollColumn = 2 ActiveWindow.ScrollColumn = 1 Range("B10").Select Selection.Cut Destination:=Range("J2") Range("J2").Select ActiveWindow.ScrollColumn = 5 ActiveWindow.ScrollColumn = 4 ActiveWindow.ScrollColumn = 3 ActiveWindow.ScrollColumn = 2 ActiveWindow.ScrollColumn = 1 Range("B11").Select Selection.Cut Destination:=Range("K2") Range("K2").Select ActiveWindow.ScrollColumn = 6 ActiveWindow.ScrollColumn = 5 ActiveWindow.ScrollColumn = 4 ActiveWindow.ScrollColumn = 3 ActiveWindow.ScrollColumn = 2 ActiveWindow.ScrollColumn = 1 Range("B12").Select Selection.Cut Destination:=Range("L2") Range("L2").Select ActiveWindow.ScrollColumn = 9 ActiveWindow.ScrollColumn = 8 ActiveWindow.ScrollColumn = 7 ActiveWindow.ScrollColumn = 6 ActiveWindow.ScrollColumn = 5 ActiveWindow.ScrollColumn = 4 ActiveWindow.ScrollColumn = 3 ActiveWindow.ScrollColumn = 2 ActiveWindow.ScrollColumn = 1 Range("A3:A13").Select Selection.EntireRow.Delete Now, my question is, how do I increment the rows and columns in each statement so that I can run the script to move every row into the relevant columns ? As always, any help appreciated. Sean. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Is it Possible to Automate a Graph? | Charts and Charting in Excel | |||
Automate MTD summation | Excel Worksheet Functions | |||
automate formula | Excel Discussion (Misc queries) | |||
Automate without add-ins | Excel Discussion (Misc queries) | |||
Automate Add-in | Excel Discussion (Misc queries) |