PDA

View Full Version : Excel help



Shaolin
12-22-2005, 08:42 AM
Helping a co-worker with year end but he's got a problem with Excel..

He's got a list of about 300 vendors on a spreadsheet.. what he wants to do is insert 5 rows under each Vendor name... Is there a way to do it with a macro?

I was thinking maybe do a subtotal for all the Vendors, do a search for the word "Total" and under each line that says "Total" insert 5 rows..

But he doesn't know how to code that in the macro.. and neither do I..

Any ideas?

FiveFreshFish
12-22-2005, 10:00 AM
Here's a quick and dirty way to do it. Assuming Row1 is the header and the vendors are in Rows 2 to 301, this will work. You can adjust the macro if there are more header rows or if the number of vendors is more or less than 300.

Be sure to run this on a copy of your worksheet so you don't kill the original. Proceed at your own risk. ;)

Sub Macro3()

Dim rowcount As Integer
Rows("302:302").Select
For rowcount = 1 To 300
Selection.Insert Shift:=xlDown
Selection.Insert Shift:=xlDown
Selection.Insert Shift:=xlDown
Selection.Insert Shift:=xlDown
Selection.Insert Shift:=xlDown
Selection.End(xlUp).Select
Next rowcount

End Sub