View Single Post
  #16   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 on 1/17/2012 :
On Jan 18, 5:15*am, GS wrote:
correction...

The code goes in the code window behind ThisWorkbook. It will run every
time the workbook is opened.


* To access the VBE keyboard *Alt+F11 *and then expand the *'Microsoft
Excel

Objects' *folder. Double-click on *'ThisWorkbook' *and paste the code.
***Make sure you edit *<sheetname *to match the name of the sheet you want
this to affect***


**Remove this codeifyou put it anywhere other than in ThisWorkbook**


--
Garry

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


Hi! Thank you so much for the explanation and taking the time to share
your knowledge...and it works! It was driving me mad! I wanted to add
another cell (M10 again but on another worksheet in the same workbook
into the code can you advise on how I do this. I tried this but it
gave me an error!

Option Explicit


Private Sub Workbook_Open()
With Sheets("<sheetname" and "<sheetname").Range("M10")
If .Value = "" Then .Value = Date
End With
End Sub

Many thanks in advance

LC


Thanks for the feedback, ..much appreciated!

You'll need to do each sheet separately so just copy/paste the code for
1 sheet and replace the sheetname accordingly.

If there are several sheets then we can set up a loop so one block of
code works for all sheets in a list. Let me know if this would be
better and I'll post new code.

--
Garry

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