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
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