Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
I'm running into a problem with putting a date in a form i'm making.
I want to have todays date populate a cell when the form is opened. But only once. So if a person opens the form for the first time it populates todays date... today(). But if they open the form up again that date will not change. If you use =today() then each time you open the form up it populates that cell with today’s date. Any idea's how i can code a cell with today’s date upon creation but not have it change each time the form is opened. Thanks for the help, Steve |
#2
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Hi Steve:
This little Workbook event macro runs whenever the workbook is opened. If Sheet1 cell A1 is empty, the date is inserted. If Sheet1 cell A1 is not empty, no insertion is made. So if the workbook is opened, saved, and re-opened, the first date is not over-written: Private Sub Workbook_Open() With Sheets("Sheet1").Range("A1") If .Value = "" Then .Value = Date End If End With End Sub Because it is workbook code, it is very easy to install and use: 1. right-click the tiny Excel icon just to the left of File on the Menu Bar 2. select View Code - this brings up a VBE window 3. paste the stuff in and close the VBE window If you save the workbook, the macro will be saved with it. To remove the macro: 1. bring up the VBE windows as above 2. clear the code out 3. close the VBE window To learn more about macros in general, see: http://www.mvps.org/dmcritchie/excel/getstarted.htm To learn more about Event Macros (worksheet code), see: http://www.mvps.org/dmcritchie/excel/event.htm -- Gary''s Student - gsnu200795 "smonczka" wrote: I'm running into a problem with putting a date in a form i'm making. I want to have todays date populate a cell when the form is opened. But only once. So if a person opens the form for the first time it populates todays date... today(). But if they open the form up again that date will not change. If you use =today() then each time you open the form up it populates that cell with todays date. Any idea's how i can code a cell with todays date upon creation but not have it change each time the form is opened. Thanks for the help, Steve |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Help needed on Date formulas | Excel Worksheet Functions | |||
Date formula needed | Excel Worksheet Functions | |||
Date formula needed | Excel Discussion (Misc queries) | |||
Help needed with date format | Excel Discussion (Misc queries) | |||
Date formulas needed | Excel Discussion (Misc queries) |