+ Reply to Thread
Results 1 to 2 of 2

VBA code required for copying rows from one tab to another

Hybrid View

  1. #1
    Registered User
    Join Date
    09-18-2007
    Posts
    16

    VBA code required for copying rows from one tab to another

    HI there

    I am struggling to complete a code for the following:

    Highlight all active rows which include data on one tab on a spreadsheet and copied across to another tab on the next available row. This is on the same spreadsheet

    Thanks

  2. #2
    Valued Forum Contributor
    Join Date
    03-23-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    1,093

    Re: VBA code required for copying rows from one tab to another

    Hello there,

    The below code should work for you.

    
    'declare variables
    Dim LR As String
    
    'select all the used cells on the worksheet entitled Sheet1
    'you'll need to change Sheet1 to fit your needs
    Sheets("Sheet1").UsedRange.Select
        
        'copy the section
        Selection.Copy
    
    'select the worksheet entitled Sheet2
    'change this to the name of the worksheet you wish to copy to
    Sheets("Sheet2").Select
        
        'set the variable LR equal to the first empty row in column A
        LR = Range("A6555").End(xlUp).Row + 1
        
        'select the first empty row and paste the information
        Range("A" & LR).Select
        Selection.PasteSpecial
    To use it press hold down the Alt key and press the F8 button. In the space provided for macro name clear the field and then type copyall. Then select the Create option.

    In between the text Sub copyall and End Sub paste the above code.
    Exit out of VBA. Anything that appears in green is a comment meant to help you understand the macro.

    To run the code select Alt F8 again then this time select the copy all macro and select run.

    Let me know if you have any questions.

    Thanks!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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