Macro to copy and insert rows in multiple worksheets

Banesmagic

New Member
Joined
Jul 26, 2007
Messages
1
I need a macro that will select all of my sheets, find the line 2 rows above a cell called Totals in column A of each sheet, copy that line and then insert the copied cell 5 times.

I have a data entry sheet for quotes with 50 or so lines with formulas to calculate the quote based on costs, rebates etc... I then have 4 different presentation sheets for different customer types which reference the data entry sheet. Each sheet in the workbook has the same number of lines. I want to be able to add 5 lines at a time to each sheet while copying the formulas (both the formulas of the data entry sheet and the references in the other sheets).

Thanks in advance to anyone who can help.
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

ravishankar

Well-known Member
Joined
Feb 23, 2006
Messages
3,566
Hi
Paste the following codes in the macro window ( Alt F11)

Code:
Sub jjj()
x = Cells(Rows.Count, 1).End(xlUp).Row
For a = 1 To Sheets.Count
b = "A1:A" & x
c = Application.WorksheetFunction.Match("Total", Worksheets(a).Range(b), 0)
Worksheets(a).Rows(c - 2).Copy
For d = 1 To 5
Worksheets(a).Rows(x + d).PasteSpecial
Next d
Next a
End Sub
Run the macro.
Ravi
 

Watch MrExcel Video

Forum statistics

Threads
1,129,347
Messages
5,635,764
Members
416,879
Latest member
Excel_Newbie4980

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top