View Single Post
  #17   Report Post  
Posted to microsoft.public.excel.misc
LCTECH001 LCTECH001 is offline
external usenet poster
 
Posts: 12
Default If cell is blank automatically enter today's date in the same cell

On Jan 18, 1:05*pm, GS wrote:
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 athttp://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc- Hide quoted text -

- Show quoted text -


Hi GS,
Another speedy response from you I see, thank you its very much
appreciated! I copy and pasted the example code below the original one
and it came back with another error!! Do you mean select the page
behind the actual worksheet and place the new code in? How will this
work if the original code for “Package Summary Report” is on “This
Worksheet” code sheet and the copied code for “Package Activity
Report” is on its corresponding code sheet? Hope I’m making sense!

Option Explicit


Private Sub Workbook_Open()
With Sheets("Package Summary Report").Range("M10")
If .Value = "" Then .Value = Date
End With
End Sub


Option Explicit


Private Sub Workbook_Open()
With Sheets("Package Activity Report").Range("M10")
If .Value = "" Then .Value = Date
End With
End Sub


Best Regards
LC