Ghostlore
08-03-2018, 02:47 AM
New to the forum and new to VBA, so hello and my apologies in advance :)
Not sure if this has been covered I looked but could not find a specific answer to my question, so here goes:
I would like to insert multiple blank rows based on cells that I have selected in the spreadsheet.
I created an ActiveX command button and entered the code below which works perfectly if I only have one cell selected. It does not work if I select more than one cell at a time.
I would like the ability to select multiple cells in the spreadsheet (via <ctrl-left click>) and then click a command button to insert a blank row below each of those selected cells.
Any help that you can provide would be greatly appreciated. Thanks for your time.
SubNewLine()
Dim topLine AsInteger: topLine =2'never insert before this line
ActiveSheet.Rows(IIf(ActiveCell.Row > topLine, _
ActiveCell.Row, _
topLine)) _
.EntireRow.Insert
End Sub
Not sure if this has been covered I looked but could not find a specific answer to my question, so here goes:
I would like to insert multiple blank rows based on cells that I have selected in the spreadsheet.
I created an ActiveX command button and entered the code below which works perfectly if I only have one cell selected. It does not work if I select more than one cell at a time.
I would like the ability to select multiple cells in the spreadsheet (via <ctrl-left click>) and then click a command button to insert a blank row below each of those selected cells.
Any help that you can provide would be greatly appreciated. Thanks for your time.
SubNewLine()
Dim topLine AsInteger: topLine =2'never insert before this line
ActiveSheet.Rows(IIf(ActiveCell.Row > topLine, _
ActiveCell.Row, _
topLine)) _
.EntireRow.Insert
End Sub