in my Sheet I'm trying to create VBA code which will allow me to: 1)add specific (constant) number of rows above clicked button 2)format them in a proper way
What I know is every object (shape) stores value of TopLeftCell which from where I can get row number. I can simply add rows(s) above or belowe specific row in my Sheet
ActiveSheet.Rows(21).Insert shift:=xlShiftDown, CopyOrigin:=xlFormatFromLeftOrAbove
I would like to create where function addNewRows2 is unviersal for any button in the ActiveSheet - it gets the position of button(the row number) and adds row(s) above it
Private Sub CommandButton2_Click()
addNewRows2
End Sub
Function addNewRows2()
Application.ActiveSheet.Buttons(Application.Caller).TopLeftCell.EntireRow.Insert
End Function