Saving a Workbook in a new subfolder using VBA

Iceman3395

New Member
Joined
Jun 2, 2017
Messages
12
Here is the current module I'm using. It works perfectly to save the workbook in the same folder as the Master Workbook.

How ever I would like to save it to a sub-folder called "F:\O&M Consultant's Calculation\using "part1" as the variable\" & part1 & " O&M " & part2 & " .xlsm"

Every time I try using "& part1" in place of red text. It does not work, even though there is a sub-folder created with the variable "part1" value. I have tried it with quotes and without cannot seem to get it work. As well as with "&" and without the &.

I even tried using a new variable called part3 but the same range("b1") and it did not work. and yes I did define the new variable.

I need to use the variable "part1" as there are different names used to create different workbooks from the Master Workbook.

Sub sb_Copy_Save_Worksheet_As_Workbook()
Dim wb As Workbook


Set wb = Workbooks.Add
ThisWorkbook.Sheets("Master Sheet").Copy Before:=wb.Sheets(1)

Dim part1 As String
Dim part2 As String


part1 = Range("b1").Value
part2 = Range("h1").Value


ActiveWorkbook.SaveAs Filename:= _
"F:\O&M Consultant's Calculation" & part1 & " O&M " & part2 & " .xlsm", FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False

End Sub
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
try
Code:
 "F:\O&M Consultant's Calculation\" & part1 & "\" & part1 & " O&M " & part2 & " .xlsm"
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,891
Messages
6,175,229
Members
452,621
Latest member
Laura_PinksBTHFT

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