Can I save an excel file as a particular cells value?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to automatically (through a macro) save an excel file as a date
and time which is the value of the A1 cell. Is there a way to incorporate
the A1 cell value in the file name when you go to save as?
 
Hi Leonard,


Try something like:

ActiveWorkbook.SaveAs Format(Range("A1").Value, _
"yyyy-mm-dd @ hh- mm")
 
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Dim str As String

If SaveAsUI Then
str = Format(Range("A1").Value, "yyyymmddhhmmss") & ".xls"
Application.EnableEvents = False
Application.Dialogs(xlDialogSaveAs).Show arg1:=str
Application.EnableEvents = True
Cancel = True
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top