macros

  • Thread starter Thread starter Dawn
  • Start date Start date
D

Dawn

I am trying to write a macro prevent users from saving
files with the wrong file name and in the wrong location.
I have the path done, however, I need to pull the file
name from a cell within the workbook.
 
Dim myPath As String
myPath = "C:\my documents\excel\test"

ActiveWorkbook.SaveAs _
Filename:=myPath & "\" & Worksheets("Sheet1").Range("a1").Value


Be careful. If there's a date in A1, you'll want to format it to make it a
valid filename:

ActiveWorkbook.SaveAs _
Filename:=myPath & "\" & _
Format(Worksheets("sheet1").Range("a1"), "yyyymmdd")
 
Back
Top