Matthew Murphy
Matthew Murphy

Reputation: 19

VBA: Saving a file in a subfolder, of which the folder and subfolder was created by vba

I have created a VBA code which creates a folder, named after a referenced cell, then within that folder I have created multiple sub folders. What I now want is a new code to save the excel sheet within one of the sub folders with a specific name, this is what I have so far. I think I am writing the path wrong or maybe using the wrong syntax. Please help ;)

I have included a copy of the code and an image hopefully it uploads correctly.

Private Sub CommandButton1_Click()
' automates the saving
Dim path As String
Dim filename1 As String

path = "T:\Estimating\Williaam Cox Project Enquiries 2018\" & Range("SaveRef") & "\Costings"

filename1 = Range("SaveRef").Text
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:=path & "Costing Sheets" & ".xlsm", FileFormat:=52
Application.DisplayAlerts = True

End Sub

enter image description here

Upvotes: 1

Views: 1181

Answers (1)

Wouter
Wouter

Reputation: 383

you're missing a "\" at the end of your path.

Upvotes: 1

Related Questions