RobExcel
RobExcel

Reputation: 191

Excel VBA to save to specific folder (with current code generating filename)

workers,

I have this code at the moment;

Public Sub SaveAsA1()
    ActiveWorkbook.SaveAs Filename:=Range("P4").Value & ";" & Range("F6").Value & ";" & Range("R6").Value & ";" & Range("R4").Value
End Sub

Which i would like to modify to be saved in a certain filemap; \S31000265\Users$\NR4236\My Documents\TV-01-project\TestmapWeek9GOED. Been trying but it keeps overwriting the Filename-code. Hope you guys can help me out.

Upvotes: 1

Views: 7460

Answers (1)

Karthick Gunasekaran
Karthick Gunasekaran

Reputation: 2713

Public Sub SaveAsA1()
    ChDir ("C:\work\testout\") ' Directory you need to save the file as xlsm
    Filename = Range("P4").Value & ";" & Range("F6").Value & ";" & Range("R6").Value & ";" & Range("R4").Value
    ActiveWorkbook.SaveAs Filename:=Filename, FileFormat:=52
End Sub

Upvotes: 2

Related Questions