fishmonger
New Member
- Joined
- Jul 28, 2022
- Messages
- 11
- Office Version
- 2016
- Platform
- Windows
I am trying to copy paste info from a "Data" Sheet to a "Master" Sheet. The "Data" and "Master" Sheet contain some sheet names in common (Master, Scenario A, Scenario B, Scenario C , Scenario D, Scenario E and Scenario F) but also have some other sheets not common in both. I would only want to copy paste the data in the common sheet names.
After copy pasting the data I would like to update the dates Starting from Z5: Z5 and AA5 should be Jan 2024 , AB5 and AC5 should be Feb 2024, AD5 and AE5 should be March 2024 and the date rename should continue until a defined month (eg I would like it to update in this pattern until Jun 2024 only and maybe another time I would want it to update in this pattern until August 2024 only)
I have the below VBA code sample for the copy pasting part but could not figure out the date updating part. I manually update the dates outside of the macro. Is there a better way to ac this copy paste part & also incorporate the date updating? Thank you.
Workbooks.Open Filename:=ThisWorkbook.Path & "\Data*"
Dim Data As Workbook
Set Data = ActiveWorkbook
Workbooks.Open Filename:=ThisWorkbook.Path & "\Summary*"
Dim Summary As Workbook
Set Summary = ActiveWorkbook
Data.Activate
Sheets("Master").Select
Columns("A:Z").Select
Selection.Copy
Summary.Activate
Sheets("Master").Select
Range("Z1").Select
ActiveSheet.Paste
Data.Activate
Sheets("Scenario A").Select
Columns("A:Z").Select
Selection.Copy
Summary.Activate
Sheets("Scenario A").Select
Range("Z1").Select
ActiveSheet.Paste
Data.Activate
Sheets("Scenario B").Select
Columns("A:Z").Select
Selection.Copy
Summary.Activate
Sheets("Scenario B").Select
Range("Z1").Select
ActiveSheet.Paste
Data.Activate
Sheets("Scenario C").Select
Columns("A:Z").Select
Selection.Copy
Summary.Activate
Sheets("Scenario C").Select
Range("Z1").Select
ActiveSheet.Paste
After copy pasting the data I would like to update the dates Starting from Z5: Z5 and AA5 should be Jan 2024 , AB5 and AC5 should be Feb 2024, AD5 and AE5 should be March 2024 and the date rename should continue until a defined month (eg I would like it to update in this pattern until Jun 2024 only and maybe another time I would want it to update in this pattern until August 2024 only)
I have the below VBA code sample for the copy pasting part but could not figure out the date updating part. I manually update the dates outside of the macro. Is there a better way to ac this copy paste part & also incorporate the date updating? Thank you.
Workbooks.Open Filename:=ThisWorkbook.Path & "\Data*"
Dim Data As Workbook
Set Data = ActiveWorkbook
Workbooks.Open Filename:=ThisWorkbook.Path & "\Summary*"
Dim Summary As Workbook
Set Summary = ActiveWorkbook
Data.Activate
Sheets("Master").Select
Columns("A:Z").Select
Selection.Copy
Summary.Activate
Sheets("Master").Select
Range("Z1").Select
ActiveSheet.Paste
Data.Activate
Sheets("Scenario A").Select
Columns("A:Z").Select
Selection.Copy
Summary.Activate
Sheets("Scenario A").Select
Range("Z1").Select
ActiveSheet.Paste
Data.Activate
Sheets("Scenario B").Select
Columns("A:Z").Select
Selection.Copy
Summary.Activate
Sheets("Scenario B").Select
Range("Z1").Select
ActiveSheet.Paste
Data.Activate
Sheets("Scenario C").Select
Columns("A:Z").Select
Selection.Copy
Summary.Activate
Sheets("Scenario C").Select
Range("Z1").Select
ActiveSheet.Paste