LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.setup
external usenet poster
 
Posts: 208
Default VBScipt: Can you hrlp me automate this ?

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is it Possible to Automate a Graph? Adam Charts and Charting in Excel 3 October 24th 06 04:19 PM
Automate MTD summation Cheryl Excel Worksheet Functions 2 July 6th 06 04:20 PM
automate formula pboost1 Excel Discussion (Misc queries) 2 March 2nd 06 07:52 PM
Automate without add-ins Rob Oldfield Excel Discussion (Misc queries) 3 October 21st 05 07:33 PM
Automate Add-in Gary's Student Excel Discussion (Misc queries) 4 June 20th 05 02:12 AM


All times are GMT +1. The time now is 05:04 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"