0

I need to run a macro that adds a row below the button the macro is assigned to and populates it relative to the rows below it. I have to use this button for several different categories. My issue is that I need to select the cell the button is in prior to running the macro for this to work. The issue with turning off relative reference is the fact that I need to insert multiple of these buttons into my spreadsheet, which would make my work very time intensive.

For reference, my first button currently is located in cell D15. This is the code that I'm running for this button.

Sub fortheinternets()
'
' fortheinternets Macro
'

'
ActiveCell.Offset(1, 0).Rows("1:1").EntireRow.Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
With Selection.Interior
    .PatternColorIndex = xlAutomatic
    .ThemeColor = xlThemeColorDark1
    .TintAndShade = 0
    .PatternTintAndShade = 0
Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73
  • 3
    Possible duplicate of [Excel VBA: getting row of clicked button](https://stackoverflow.com/questions/6242605/excel-vba-getting-row-of-clicked-button) – Pᴇʜ Apr 17 '18 at 15:02
  • If you know all the specific cells you want to place a button on and your macro performs the same task for every new row? I would suggest you use only one button to assign an Array containing all the cells and then loop through the array and place your `EntireRow.Insert` code in the loop. – GMalc Apr 17 '18 at 19:43

0 Answers0