Results 1 to 5 of 5

Select Any Cell and Copy Entire Row, Then Paste Data to New Worksheet

Threaded View

  1. #1
    Forum Contributor
    Join Date
    08-04-2018
    Location
    San Dieg CA
    MS-Off Ver
    Microsoft Office Professional Plus 2016 (Excel 2016 MSO 32 bit)
    Posts
    167

    Select Any Cell and Copy Entire Row, Then Paste Data to New Worksheet

    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
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. If cells match from one worksheet to another, copy / paste entire column.
    By iracknback in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 12-05-2016, 11:19 AM
  2. [SOLVED] Copy/paste entire row if a cell in that row contains specific data
    By SamYounno in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-17-2015, 10:53 AM
  3. Replies: 2
    Last Post: 12-04-2013, 11:49 AM
  4. Replies: 4
    Last Post: 10-25-2012, 05:09 PM
  5. Loop to check 2 variables then copy/paste entire row to new worksheet
    By patrick riley in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-02-2012, 02:10 PM
  6. [SOLVED] Copy entire row in one worksheet, paste in next blank row in another worksheet
    By dev111ski in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-20-2012, 01:02 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1