: hi all,
please help me in the below vba code, as beginner
in the work sheet, just want to insert the multiple rows through input box and insert after which row through input box.
then i make which row to be copied through input box.
i cannot paste the copied row to the number of rows inserted.
For example, if im inserting 10 rows, after row number 12.
and copying the row number 9 of selected range as (A9:M9), and paste with formula & Formats to newly inserted rows. (This pasting part code im not getting correct)
Private Sub CommandButton1_Click()
Dim iRow As Long
Dim iCount As Long
Dim cRow As Long
Dim i As Long
iCount = InputBox(Prompt:="How many rows you want to add?")
iRow = InputBox _
(Prompt:="After which row you want to add new rows? (Enter the row number")
For i = 1 To iCount
Rows(iRow).EntireRow.Insert
Next i
cRow = InputBox(Prompt:="Which row you need to copy? (Enter the row number)")
Rows("AcRow:LcRow").Select
Selection.Copy
Application.CutCopyMode = False
'Paste formulas and conditional formatting in new row created
Rows(iRow + iCount).PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone
End Sub
please help me in the below vba code, as beginner
in the work sheet, just want to insert the multiple rows through input box and insert after which row through input box.
then i make which row to be copied through input box.
i cannot paste the copied row to the number of rows inserted.
For example, if im inserting 10 rows, after row number 12.
and copying the row number 9 of selected range as (A9:M9), and paste with formula & Formats to newly inserted rows. (This pasting part code im not getting correct)
Private Sub CommandButton1_Click()
Dim iRow As Long
Dim iCount As Long
Dim cRow As Long
Dim i As Long
iCount = InputBox(Prompt:="How many rows you want to add?")
iRow = InputBox _
(Prompt:="After which row you want to add new rows? (Enter the row number")
For i = 1 To iCount
Rows(iRow).EntireRow.Insert
Next i
cRow = InputBox(Prompt:="Which row you need to copy? (Enter the row number)")
Rows("AcRow:LcRow").Select
Selection.Copy
Application.CutCopyMode = False
'Paste formulas and conditional formatting in new row created
Rows(iRow + iCount).PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone
End Sub