View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
RJD RJD is offline
external usenet poster
 
Posts: 6
Default Update date & time in a cell only when worksheet is changed

Hi,
It's still not working. I pasted Mike's code in the "ThisWorkbook" VB editor
and changed ("A1") to ("H1"). I went back to the Excel file and wrote "test"
in an empty cell (not H1) of Worksheet 1 and hit "Enter." Nothing appears in
H1.

Does it matter how the cell is formatted? Right now its set for "General"
formatting.

I appreciate your help and patience.

RJD


"Gord Dibben" wrote:

RJD

After returning to Excel from VBE you must select any cell except G1 on any
sheet.

Make a change and ENTER. The date/time will appear in G1.

Having the code in Thisworkbook saves you the duplicating the code in each
worksheet.

If you just wanted it for one sheet you would change the event type to

Private Sub Worksheet_Change(ByVal Target As Range)

and paste it into the sheet module.

Mike has steered you correctly because you wanted it for every sheet in the
workbook.


Gord Dibben MS Excel MVP


On Wed, 16 Dec 2009 07:32:01 -0800, RJD
wrote:

Mike,

Thanks for your reply to my question. I'm new to "writing code" to
accomplish something like this Excel. I followed your instructions but may
have missed something obvious to a more experience user.

I pasted the code you provided in the window as you instructed, and changed
("A1") to ("G1") so the date & time would be in the G1 cell of my first
worksheet. I selected ALT+F11 again to go back to the worksheet and nothing
appears in G1 of worksheet 1. I'm sure your code is right and it's something
I'm doing wrong.

Since I want the date & time in each worksheet, wouldn't I select the
specific sheet instead of "ThisWorkbook" and paste the code?

I may need a little more detail in how to use VB editor this first time to
get this right.

Thanks,

RJD


"Mike H" wrote:

Hi,

You need code for that. ALT+F11 to open VB editor. Double click
'ThisWorkbook and paste the code below in on the right. Change the cell to
the one you want

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Application.EnableEvents = False
ActiveSheet.Range("A1").Value = Now
Application.EnableEvents = True
End Sub

Mike

"RJD" wrote:

I have a workbook with multiple worksheets. I'd like to have the time & date
in a cell in each worksheet update only when information in that worksheet is
changed. I don't change each worksheet each time I use the workbook. I tried
=NOW(), but it changes the time and date in each worksheet.


.