Good evening.
I've recorded a Macro (I'm new to this process) that copies and pastes data from two workbooks into a table in yet a 3rd 'Calc' wb. As you can see, the "HIST" file is first followed by the "WIP" file.
The problem I'm having is that the 'Hist' file varies in number of rows from day to day. Currently, if the Hist file is longer than the file I used when recording the Macro, the WIP file overlaps Historical data. Conversely, on days when the 'Hist' file is shorter, the WIP data is pasted somewhere below the table.
So, how do I get the WIP data copied and pasted directly beneath the Hist data regardless of the number of rows in the Hist file?
Thanks, Steve
Sub GetData()
'
' GetData Macro
'
'
Range("WIP[WC]").Select
ChDir "C:\Users\Steve\Desktop\Test folder"
Workbooks.Open Filename:="C:\Users\Steve\Desktop\Test folder\HIST.xlsx"
Range("A2:O2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Windows("Morning Prod Calc (v1.5a).xlsx").Activate
ActiveSheet.Paste
Workbooks.Open Filename:="C:\Users\Steve\Desktop\Test folder\WIP.xlsx"
Range(Selection, Cells(ActiveCell.Row, 1)).Select
Range("A2:O2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Windows("Morning Prod Calc (v1.5a).xlsx").Activate
Range("A2").Select
Selection.End(xlDown).Select
Range("A12").Select
ActiveSheet.Paste
Cells.Select
Cells.EntireColumn.AutoFit
Range("A2").Select
End Sub
Bookmarks