Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default Logging an update

The other day some real great people gave me some code to enter "NOW" in a
cell when the cell is double clicked. It kind of works, but not exactly like
I need. I need for the code to insert the current date and time in cell $A$1
when the cell is double clicked, regardless of what is already in that cell.
The code is put in the Workbook module because it effects more than one
sheet. The code I have follows:

Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal Target _
As Range, Cancel As Boolean)
If Target.Address = "$A$1" And Target.Value<"" Then
Target.Value = Format(Now, "mm/dd/yyyy hh:mm:ss")
End If
Cancel = True
End Sub

This seems to work the first time the cell is double clicked, but after
that, it won't change the information. The "NOW" information is used to show
that last time the page was updated, and it may be changed more than once.

Any suggestions?
Thanks everyone,
--
Howard
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Logging an update

You're checking two conditions. That A1 is the cell that you're doubleclicking
in and that it's empty to start.

If Target.Address = "$A$1" And Target.Value<"" Then

If you don't want to check for emptyness:

If Target.Address = "$A$1" Then



Howard wrote:

The other day some real great people gave me some code to enter "NOW" in a
cell when the cell is double clicked. It kind of works, but not exactly like
I need. I need for the code to insert the current date and time in cell $A$1
when the cell is double clicked, regardless of what is already in that cell.
The code is put in the Workbook module because it effects more than one
sheet. The code I have follows:

Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal Target _
As Range, Cancel As Boolean)
If Target.Address = "$A$1" And Target.Value<"" Then
Target.Value = Format(Now, "mm/dd/yyyy hh:mm:ss")
End If
Cancel = True
End Sub

This seems to work the first time the cell is double clicked, but after
that, it won't change the information. The "NOW" information is used to show
that last time the page was updated, and it may be changed more than once.

Any suggestions?
Thanks everyone,
--
Howard


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default Logging an update

Hi Howard

If you replace this line
If Target.Address = "$A$1" And Target.Value < "" Then
With this:
If Target.Address = "$A$1" Then
Remove ( and Target.Value<"")
It will print time & Date even if the cell is empty.
HTH
John
"Howard" wrote in message
...
The other day some real great people gave me some code to enter "NOW" in a
cell when the cell is double clicked. It kind of works, but not exactly like
I need. I need for the code to insert the current date and time in cell $A$1
when the cell is double clicked, regardless of what is already in that cell.
The code is put in the Workbook module because it effects more than one
sheet. The code I have follows:

Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal Target _
As Range, Cancel As Boolean)
If Target.Address = "$A$1" And Target.Value<"" Then
Target.Value = Format(Now, "mm/dd/yyyy hh:mm:ss")
End If
Cancel = True
End Sub

This seems to work the first time the cell is double clicked, but after
that, it won't change the information. The "NOW" information is used to show
that last time the page was updated, and it may be changed more than once.

Any suggestions?
Thanks everyone,
--
Howard


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Logging changes SPISO Excel Discussion (Misc queries) 0 May 12th 09 05:44 PM
logging out Tom Excel Programming 0 August 2nd 06 10:45 PM
Logging into a website Jackblack1 Excel Discussion (Misc queries) 0 May 31st 06 05:27 PM
Change Logging Matt Jensen Excel Programming 0 December 20th 04 05:48 PM
Logging things.. Foss Excel Programming 2 April 8th 04 12:31 PM


All times are GMT +1. The time now is 07:27 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"