Results 1 to 5 of 5

Macro to copy paste Tables to Master sheet

Threaded View

  1. #1
    Registered User
    Join Date
    03-04-2010
    Location
    Wisconsin
    MS-Off Ver
    Excel 2007, Excel 2010, Excel 2003
    Posts
    87

    Macro to copy paste Tables to Master sheet

    Hi all,

    Figured I would end the year with a macro question that involves copying and pasting data from multiple worksheets to one. I tried the macro recorder however, (as I am creating an nVision layout) the number of lines (data) will change month to month or whatever the user ends up putting as a date range. So, How do I create a macro that will go and get Table1 and Table2 and paste it all on the "MASTER" Worksheet?

    I am attaching the following: sample of the macro I tried based on what other individuals have written and the before and after results that I hope to achieve with this macro.
    I will also need to adjust the macro so that it is compatible with Excel 2003. (So do I need 2 different macros? One for 2003 Excel and One for 2010 Excel?) I am having difficulties with how to instruct it to go to the first blank cell in Column B after pasting the results from the REV_SHR worksheet on the Master sheet without embedding an actual cell location.

    Sheets("MASTER").Select
    Range("B4").Select
    Selection.End(xlDown).Select
    Range("B122").Select This is the part I think needs to be changed so that it is more flexible How do I code it so that it is "xldown + 1 row"?
    ActiveSheet.Paste

    Please note that I colored the sections so as to show where the data is coming from, but do not want that to be part of the macro. Any and all help is greatly appreciated!! Happy New Year too!

    Sub CopySheets()
    '
    ' CopySheets Macro
    ' Copy data from REV Sheets Paste to Master, Filter Master, then Hide Sheet 1
    '
    
    '
        Sheets("REV_SHR").Select
        Range("B4").Select
        Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
        Range("Table1").Select
        Selection.Copy
        Sheets("MASTER").Select
        Range("B4").Select
        ActiveSheet.Paste
        Range("B4").Select
        Sheets("REV_SHR").Select
        Application.Goto Reference:="R2C1"
        Sheets("REV_SUM").Select
        Range("B4").Select
        Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
        Range("Table2").Select
        Application.CutCopyMode = False
        Selection.Copy
        Sheets("MASTER").Select
        Range("B4").Select
        Selection.End(xlDown).Select
        Range("B122").Select
        ActiveSheet.Paste
        Range("A1").Select
        Sheets("REV_SUM").Select
        Application.Goto Reference:="R2C1"
        Sheets("MASTER").Select
        Range("B3:P3").Select
        Application.CutCopyMode = False
        Selection.AutoFilter
        Application.Goto Reference:="R2C1"
        Sheets("Sheet1").Select
        ActiveWindow.SelectedSheets.Visible = False
    End Sub
    Attached Files Attached Files
    Last edited by dawnmau; 01-02-2013 at 05:54 PM. Reason: Solved!!
    Dawn - Guru in Training

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