I have me some code which inserts a duplication of the selected row, above.
Question 1 -
Using the code below, how do I get it to insert the new row below the selcted row, rather than above?
VBA code:
Private Sub CommandButton1_Click()
Worksheets("Sheet1").Unprotect Password:="#######"
Dim currentRow As Integer
Dim currentCol As Integer
Dim tpnbNew As Integer
'tpnbNew = InputBox("Please enter your new TPNB")
' where is the cursor
currentRow = ActiveCell.Row
currentCol = ActiveCell.Column
' insert now row above current row
Rows(currentRow & ":" & currentRow).Select
Selection.Insert Shift:=xlDown
' select old row (since currentRow was shifted down one this is now currentRow+1, select to end and copy
Range("A" & currentRow + 1, "IV" & currentRow + 1).Select
Selection.Copy
' select first cell in dest row and paste
Range("A" & currentRow).Select
ActiveSheet.Paste
' restore cursor to correct column in new row
Cells(currentRow, currentCol).Select
Worksheets("Sheet1").Protect Password:="######"
End Sub
Question 2, how would I tell it to empty selected cells within the new row? The cell column will always be the same, but from the row, there are about 6 cells which need to be copied 'blank'.
Question 3 - is there a way of populating these newly-emptied cells with values from a user form / or pop-up box (you'll see in the code I've created 1 popup box, and have also created a blank form in vba to use)
thanks very much!