Hello Everyone,
I have the below code. When I click the command button an inputbox appears and I’m able select a range of cells of my choosing. Then when I click OK, it pastes it to another sheet (Sheet2). Although it works, I’d like some help modifying it. I want to do away with the inputbox altogether. I want to just select any cell in a row and copy the entire row. Then when I click the command button, go to sheet2 and paste the data to last empty row of sheet2. And last, delete the copied row from sheet1. I’ve attached the file for further clarity. If anyone could help, I’d really appreciated it.
Private Sub CommandButton2_Click()
Dim xScreenUpdating As Boolean
Dim xPasteSht As Worksheet
Dim xRg As Range
Dim xTxt As String
On Error Resume Next
xTxt = ActiveWindow.RangeSelection.Address
Set xRg = Application.InputBox("Please select a range:", "Kutools for Excel", xTxt, , , , , 8)
If xRg Is Nothing Then Exit Sub
Set xPasteSht = Worksheets("Sheet2")
xScreenUpdating = Application.ScreenUpdating
Application.ScreenUpdating = False
xRg.Copy
xPasteSht.Cells(Rows.Count, 2).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
Application.CutCopyMode = False
Application.ScreenUpdating = xScreenUpdating
End Sub
Bookmarks