View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
GS[_2_] GS[_2_] is offline
external usenet poster
 
Posts: 3,514
Default If cell is blank automatically enter today's date in the same cell

LCTECH001 explained :
Can someone please help with the following? I have a blank cell in say M10
which when a date is typed into it is used in another formula which counts
all those entries before that date which are overdue. What I would like to
happen is if the cell is blank then todays date is automatically entered. I
have tried the following formula but all I get is the word FALSE and I need
todays Date. Can someone out there please assist?

=IF(ISBLANK(""),TODAY())


Thanks


You can't use a formula in M10 because it would be a circular reference
(refers to itself). What you need is a macro to enter today's date,
something like...

In a standard code module:

Option Explicit

Sub SetTodaysDate()
With Range("M10")
If .Value = "" Then .Value = Date
End With
End Sub

...which you could call from the Worksheet_Activate event...

In the code module behind the worksheet:

Option Explicit

Private Sub Worksheet_Activate()
Call SetTodaysDate
End Sub

--OR--

...simply use the Worksheet_Activate event...

Private Sub Worksheet_Activate()
With Range("M10")
If .Value = "" Then .Value = Date
End With
End Sub

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc