VBA to add a new row in reference to a specific row/cell

mwilburn

New Member
Joined
Jul 31, 2018
Messages
13
I have a worksheet that has my companies action items and client action items. I have macros that add new copied rows with conditional formatting and formulas. The macros I have work but they add a new row under a specified row (18 and 29) which obviously causes issues if I add 4 or 5 rows to the top section.

In short, what I need to do is, instead of adding a row below Row 29, I need it to add a row in 2 rows below wherever the button is located. Is that possible?

Here is what I have, and yes, it's very simple. I am new to macros and VBA and all of this. Thank you for your time.

Sub AddNewRowAgendaTop()
'
' AddNewRowAgendaTop Macro
'


'
Rows("18:18").Select
Selection.Copy
Selection.Insert Shift:=xlDown
End Sub


Sub AddNewRowAgendaBottom()
'
' AddNewRowAgendaBottom Macro
'


'
Rows("29:29").Select
Application.CutCopyMode = False
Selection.Copy
Selection.Insert Shift:=xlDown
End Sub
 
Last edited:
That is correct!

.
I looked up a chart of ASCII characters .... can't say I recognize those characters.

What are they ?

Never mind, just found another chart of WingDings that relate to the ASCII characters.
One is a checkbox (checked) and the other is a checkbox (unchecked).

So you don't require your code to be worked into the macro ? Is that what you are saying ?
 
Upvote 0

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
I think I am almost where I need to be but not 100% If I use this code...

"Sub insertrows() ActiveCell.EntireRow.Offset(1).Resize(2).Insert Shift:=xlDown
End Sub"

...it does what I want to in terms of adding the row. Was there a way to get this to paste in a copied row?

This is almost there. It does paste a new row to the same place in reference to the cell and not to a designed row (which is awesome) but how do I get it to copy and paste in a row with the formatting?
 
Upvote 0

Forum statistics

Threads
1,216,732
Messages
6,132,409
Members
449,726
Latest member
Skittlebeanz

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