Macro to Insert Current Date into cell - Macro to "Save As"

G

Guy

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
 
B

Brotha Lee

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
 
G

Guy

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".
 
G

Guy

The "SaveAs" macro works but the "Date" macro is not working. I'm not sure
how to set it up.
 

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

Top