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

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
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,224,825
Messages
6,181,191
Members
453,021
Latest member
pingpong7117

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