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
Bookmarks