Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50061

Clear Contents in an insert rows x number of times Macro

$
0
0
I have a macro that inserts a number of rows (input by the user) at the next available row, I just need this to also clear the contents. I tried inserting Selection.ClearContents into the code but I'm new to this and wasn't sure where to put it. Any help much appreciated:

Private Sub CommandButton15_Click()
Dim lngRows As Long, lngNextRow As Long

On Error GoTo Finish

lngRows = CLng(InputBox("How many rows do you wish to insert?"))
lngNextRow = Range("A" & Rows.Count).End(xlUp).Row + 1

Rows(43).Copy Rows(lngNextRow & ":" & lngNextRow + lngRows - 1)

Finish:
If Err.Number <> 0 Then MsgBox Prompt:="Please ensure you only enter numeric values!"

End Sub




:eek:

Thanks in advance

Viewing all articles
Browse latest Browse all 50061

Trending Articles