Did you want a new file to be created each time you run the macro or do you want to copy the data to one file each time with the data added to the bottom of the existing data in the Input sheet?
Did you want a new file to be created each time you run the macro or do you want to copy the data to one file each time with the data added to the bottom of the existing data in the Input sheet?
You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
Practice makes perfect. I'm very far from perfect so I'm still practising.
Thanks for your quick reply...I'd like to create a new file each time and have the name of this file = to whatever is in cell A3 of the "Sched_Example" file.
I've created a template file that replicates most of what I need:
Dim strTemplate As String: strTemplate = "Path\template.xlsx"
Dim wb As Workbook
Set wb = Workbooks.Add(strTemplate)
This works perfectly but I am not sure how to then cut and land the data into the newly-created workbook. It also obvi doesn't change the file name as I described earlier.
Can you attach a copy of the template file? You can only change the name of the file when you save it. What is the full path to the folder where you want to save the new file? Is the template file in the same folder?
Dim strTemplate As String: strTemplate = "C:\Users\havenc\Desktop\Upwork\Model_Template.xlsx"
Dim wb As Workbook
Set wb = Workbooks.Add(strTemplate)
Yes, they would be saved in the same folder.
I assume you want to copy the data from the "Outputs" sheet in Sched_Example to the "Input" sheet of the template starting in column P. If that is correct, the setup of the 2 sheets is different in that the "Input" sheet of the template has formulas in rows 6, 10 and 11. If we simply copy the data from the "Outputs" sheet in Sched_Example to the "Input" sheet of the template, the formulas will be overwritten. Could you please clarify in detail which rows of data you want to copy from the "Outputs" sheet and exactly where in the "Input" sheet you want to paste that data.
All apologies,
=> B12:M12 in "Sched_Example" would paste into Q4:AB4
=> B13:M13 in "Sched_Example" would paste into Q5:AB5
=> B14:M15 in "Sched_Example" would paste into Q8:AB9
Place this macro in a standard module in the Sched_Example workbook and run it from there.
![]()
Sub CopyDataAndSave() Application.ScreenUpdating = False Dim desWB As Workbook, desWS As Worksheet, srcWS As Worksheet Set srcWS = ThisWorkbook.Sheets("Outputs") Set desWB = Workbooks.Open(Environ("userprofile") & "\Desktop\Upwork\Model_Template.xlsx") Set desWS = Sheets("Input") With srcWS .Range("B12:M13").Copy desWS.Range("Q4") .Range("B14:M15 ").Copy desWS.Range("Q8") End With ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.Path & Application.PathSeparator & srcWS.Range("A3").Value & ".xlsx", FileFormat:=51 Application.ScreenUpdating = True End Sub
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks