VBA Help: How to dynamically change two folder paths based on a cell value, and save the copied sheets without formulas?

nmartin

New Member
Joined
May 26, 2018
Messages
4
Hi, I found the below VBA code below and it works but I would like to change the last two folders that are highlighted in yellow dynamically based on cell values located on the NewPreShiftSheet, the year cell is located in O3 and the month is located in O2?





Rich (BB code):
Sub Copy_Save_Lineup_Recap_New_Workbook()
'
' Copy_Save_Lineup_Recap_New_Workbook Macro
'


    Dim FName           As String
    Dim FPath           As String
    Dim NewBook         As Workbook

    FPath = "\\Daily Line Up\2020\3. Mar"
    FName = "Recap " & Format(Date, "m-d") & ".xlsx"

    Set NewBook = Workbooks.Add

    ThisWorkbook.Sheets(Array("NewPreShiftSheet", "Recap")).Copy Before:=NewBook.Sheets(1)

    If Dir(FPath & "\" & FName) <> "" Then
        MsgBox "File " & FPath & "\" & FName & " already exists"
    Else
        NewBook.SaveAs Filename:=FPath & "\" & FName
    End If

End Sub
 
Last edited by a moderator:

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Forum statistics

Threads
1,214,605
Messages
6,120,476
Members
448,967
Latest member
visheshkotha

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top