ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Macro to Insert Current Date into cell - Macro to "Save As" (https://www.excelbanter.com/excel-worksheet-functions/213225-macro-insert-current-date-into-cell-macro-save.html)

Guy[_2_]

Macro to Insert Current Date into cell - Macro to "Save As"
 
Windows XP - Office Basic 2003 - Excell 2003

1) I need a macro that will insert the current date into a cell. I do not
want the date to change when the sheet is opened or modified and saved unless
that macro button is selected.

2) I also need a macro that will bring up the "Save As" window when button
is selected. If possible to also insert a particular cell value in name field
of "Save As" window, then save and exit all with same macro.

Thanks,
Guy

Brotha Lee

Macro to Insert Current Date into cell - Macro to "Save As"
 
Hi Guy,

The following codes will do the trick for you:

Sub SetDate()
'Set cell A1 to the current date
ActiveSheet.Range("A1").Value = Date
End Sub

Sub SaveAs()
'Open the save as dialog box and show the value from A1
Dim myValue As String

myValue = ActiveSheet.Range("A1").Value
Dim fd As Dialog
Set fd = Application.Dialogs(xlDialogSaveAs)

If fd.Show(myValue) = False Then
'User pressed cancel, sheet not saved
'Add any additional code here if necessary
Else
'User has saved the file, update the data in range A1
'Run SetDate macro
SetDate
End If
End Sub

"Guy" wrote:

Windows XP - Office Basic 2003 - Excell 2003

1) I need a macro that will insert the current date into a cell. I do not
want the date to change when the sheet is opened or modified and saved unless
that macro button is selected.

2) I also need a macro that will bring up the "Save As" window when button
is selected. If possible to also insert a particular cell value in name field
of "Save As" window, then save and exit all with same macro.

Thanks,
Guy


Guy[_2_]

Macro to Insert Current Date into cell - Macro to "Save As"
 
I think you are giving me too much credit for knowing about macros, I am
mearly a novice. I think I need a little more instruction on how to apply
this macro. The date cell will be "E2".

--
GT


"Brotha Lee" wrote:

Hi Guy,

The following codes will do the trick for you:

Sub SetDate()
'Set cell A1 to the current date
ActiveSheet.Range("A1").Value = Date
End Sub

Sub SaveAs()
'Open the save as dialog box and show the value from A1
Dim myValue As String

myValue = ActiveSheet.Range("A1").Value
Dim fd As Dialog
Set fd = Application.Dialogs(xlDialogSaveAs)

If fd.Show(myValue) = False Then
'User pressed cancel, sheet not saved
'Add any additional code here if necessary
Else
'User has saved the file, update the data in range A1
'Run SetDate macro
SetDate
End If
End Sub

"Guy" wrote:

Windows XP - Office Basic 2003 - Excell 2003

1) I need a macro that will insert the current date into a cell. I do not
want the date to change when the sheet is opened or modified and saved unless
that macro button is selected.

2) I also need a macro that will bring up the "Save As" window when button
is selected. If possible to also insert a particular cell value in name field
of "Save As" window, then save and exit all with same macro.

Thanks,
Guy


Guy[_2_]

Macro to Insert Current Date into cell - Macro to "Save As"
 
The "SaveAs" macro works but the "Date" macro is not working. I'm not sure
how to set it up.

--
GT


"Guy" wrote:

I think you are giving me too much credit for knowing about macros, I am
mearly a novice. I think I need a little more instruction on how to apply
this macro. The date cell will be "E2".

--
GT


"Brotha Lee" wrote:

Hi Guy,

The following codes will do the trick for you:

Sub SetDate()
'Set cell A1 to the current date
ActiveSheet.Range("A1").Value = Date
End Sub

Sub SaveAs()
'Open the save as dialog box and show the value from A1
Dim myValue As String

myValue = ActiveSheet.Range("A1").Value
Dim fd As Dialog
Set fd = Application.Dialogs(xlDialogSaveAs)

If fd.Show(myValue) = False Then
'User pressed cancel, sheet not saved
'Add any additional code here if necessary
Else
'User has saved the file, update the data in range A1
'Run SetDate macro
SetDate
End If
End Sub

"Guy" wrote:

Windows XP - Office Basic 2003 - Excell 2003

1) I need a macro that will insert the current date into a cell. I do not
want the date to change when the sheet is opened or modified and saved unless
that macro button is selected.

2) I also need a macro that will bring up the "Save As" window when button
is selected. If possible to also insert a particular cell value in name field
of "Save As" window, then save and exit all with same macro.

Thanks,
Guy


Guy[_2_]

Macro to Insert Current Date into cell - Macro to "Save As"
 
Figured it out and got it to work. Thanks.

Guy
--
GT


"Brotha Lee" wrote:

Hi Guy,

The following codes will do the trick for you:

Sub SetDate()
'Set cell A1 to the current date
ActiveSheet.Range("A1").Value = Date
End Sub

Sub SaveAs()
'Open the save as dialog box and show the value from A1
Dim myValue As String

myValue = ActiveSheet.Range("A1").Value
Dim fd As Dialog
Set fd = Application.Dialogs(xlDialogSaveAs)

If fd.Show(myValue) = False Then
'User pressed cancel, sheet not saved
'Add any additional code here if necessary
Else
'User has saved the file, update the data in range A1
'Run SetDate macro
SetDate
End If
End Sub

"Guy" wrote:

Windows XP - Office Basic 2003 - Excell 2003

1) I need a macro that will insert the current date into a cell. I do not
want the date to change when the sheet is opened or modified and saved unless
that macro button is selected.

2) I also need a macro that will bring up the "Save As" window when button
is selected. If possible to also insert a particular cell value in name field
of "Save As" window, then save and exit all with same macro.

Thanks,
Guy



All times are GMT +1. The time now is 07:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com