views:

46

answers:

1

How do I write a macro that copies columns into a list and inserts some words in between? Like follows:

John Doe            1256            856
Jane Doe            5462            564
Tom...

becomes

John Doe
word
word
word
word
1256
word
word
856
Jane Doe
word
word
word
word
word
5462
word
word
564
Tom.....

The word is constant in that it is between the data a fix number of times (4 and 2 in this example). There are about 300 columns that I need to rip the data from into a list.

+7  A: 

The golden rule for Excel macros is to turn on the macro recorder, perform the action you want automated two or three times and then have a look at the recorded macro.

You usually just need to replace the three separate actions by a For or While loop that processes all your data.

Ah,and if you want to switch between different worksheets in Excel (because you have your source data in one sheet and want to store your results in a second one, for example), remember to set Application.Screenupdating to False before entering your loop, and to True after completing the loop, this will speed up the execution time quite a bit.

Treb
This is what I have, but evertime I try to loop to continue through the columns, it overwrites, because the copy and pastes just overwrites the exact cell. I have tried the active cell (1, 0) line, but it only works once and then goes back to stated cell....does this make sense. I could start with an easier layout and build, but basically need to loop through 2 columns to create list.
Jon
In that case you *should* store the result independent from your input data. One way would be to write it into a text file, but since Excel is already running, I would recommend a separate spreadsheet ;-) You can switch between sheets within one Excel document with `Sheets("*EnterDesiredSheetNameHere*").Select`.
Treb