SamirBhowmik
New Member
- Joined
- Sep 23, 2021
- Messages
- 26
- Office Version
- 365
- 2013
- Platform
- Windows
Hello,
I am quite new to VBA. I have a file where I want to insert a row after leaving out the immediate row below the active cell, and paste the contents of the row of the active cell to the inserted row in values (as in no colours, formulas etc.). I have this below code:
Sub copy_paste()
ActiveCell.EntireRow.Copy
ActiveCell.Offset(2).PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
ActiveScreenUpdate = False
End Sub
I want bring some modifications to it:
1. Assign this to a button where once clicked the button would ask me how many rows I want to insert and once i mention the number, it should insert the number of rows and paste the content of the row to those newly inserted rows.
2. Also if clicked second time, the same function should add new rows instead of replacing the existing ones.
3. Lastly, after all that the cursor or the active cell should be back to the active cell from where I initiated the process
Can anyone help me to achieve this please?
Thank you
I am quite new to VBA. I have a file where I want to insert a row after leaving out the immediate row below the active cell, and paste the contents of the row of the active cell to the inserted row in values (as in no colours, formulas etc.). I have this below code:
Sub copy_paste()
ActiveCell.EntireRow.Copy
ActiveCell.Offset(2).PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
ActiveScreenUpdate = False
End Sub
I want bring some modifications to it:
1. Assign this to a button where once clicked the button would ask me how many rows I want to insert and once i mention the number, it should insert the number of rows and paste the content of the row to those newly inserted rows.
2. Also if clicked second time, the same function should add new rows instead of replacing the existing ones.
3. Lastly, after all that the cursor or the active cell should be back to the active cell from where I initiated the process
Can anyone help me to achieve this please?
Thank you