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

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,066
Messages
5,835,195
Members
430,346
Latest member
Emaus_Sedan

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