Macro to copy row with relative positioning and insert above active cell

tlrowe9065

New Member
Joined
Sep 28, 2023
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Newbie to macros. I have 4 different "template" rows at the bottom of my very long spreadsheet that contain various formulas. Needing macros that can copy each of the rows and insert above the active cell wherever it is. Having trouble with the positioning as each time a row is inserted, the template rows move.

Eventual goal is to have the macros assigned to 4 different floating buttons where we can simply position the cursor and click the button for the type of row we want copied/inserted at that location.

Any help is greatly appreciated!!
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Welcome to MrExcel.
Having trouble with the positioning as each time a row is inserted, the template rows move.
Put the 4 different "template" rows to 4 named range & use those named range in the macro.
Eventual goal is to have the macros assigned to 4 different floating buttons
Could you show us your macro?
 
Upvote 0
Solution
Thank you for your reply. After setting the named ranges on my "template" rows, I was able to do it without a macro. I found some code on another post that I put in the Click event for my buttons. Seems to work for what I need. Thanks again for the info!

Private Sub InsertRange1()

Dim ws As Worksheet
Set ws = Sheets("Sheet1")
ws.Range("Test1").Copy
'Edit your named range here (i.e. replace "Test1")
ActiveCell.Insert Shift:=xlDown
Application.CutCopyMode = False

End Sub
 
Upvote 0
You're welcome, glad to help & thanks for the feedback.:)
 
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,959
Members
449,096
Latest member
Anshu121

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
Back
Top