Brussel_Sproutington
New Member
- Joined
- May 25, 2021
- Messages
- 3
- Office Version
- 365
- Platform
- Windows
Hello! I'm new to the forums and I am new to VBA.
I have a set of reports that run every week and are sorted into specific files with specific names. The data in these reports is always formatted the same.
What I need my code to do is, open a workbook, copy the column (under the header, B2 and below), and paste it into a master workbook that archives all this data in their own respective sheets. That data column would be pasted at the first open column space under a new header starting in row 3. So, if C3 was the first spot open it would paste there, if D3 was open it would paste there, then E3, etc.
I have gathered and pieced together code that does roughly what I want, but I need help.
This code grabs the data from the correct place and puts it in the correct sheet, the only issue is that it places the code at the bottom of the first row instead of the next open column.
Could someone help me alter this so that it places the data properly?
Thank you!
I have a set of reports that run every week and are sorted into specific files with specific names. The data in these reports is always formatted the same.
What I need my code to do is, open a workbook, copy the column (under the header, B2 and below), and paste it into a master workbook that archives all this data in their own respective sheets. That data column would be pasted at the first open column space under a new header starting in row 3. So, if C3 was the first spot open it would paste there, if D3 was open it would paste there, then E3, etc.
I have gathered and pieced together code that does roughly what I want, but I need help.
This code grabs the data from the correct place and puts it in the correct sheet, the only issue is that it places the code at the bottom of the first row instead of the next open column.
VBA Code:
Code:
Dim wsCopy As Worksheet
Dim wsDest As Worksheet
Dim lCopyLastRow As Long
Dim lDestLastRow As Long
Workbooks.Open "M:\Engineering personnel\Brussel_Sproutington\Automated 6Pack\15Labor hours for PMs per craft\Labor hours for PMs per Craft Current.xls" 'Open Spreadsheet
Set wsCopy = Workbooks("Labor hours for PMs per Craft Current.xls").Worksheets(1)
Set wsDest = Workbooks("6Pack MasterSheet Copy.xlsm").Worksheets("Auto Graph 15 LHfPM")
lCopyLastRow = wsCopy.Cells(wsCopy.Rows.Count, "A").End(xlUp).Row
lDestLastRow = wsDest.Cells(wsDest.Rows.Count, "A").End(xlUp).Offset(1).Row
wsCopy.Range("A2:B" & lCopyLastRow).Copy _
wsDest.Range("A" & lDestLastRow)
Workbooks("Labor hours for PMs per Craft Current.xls").Close SaveChanges:=True 'Close Spreadsheet
Could someone help me alter this so that it places the data properly?
Thank you!