LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,203
Default Working with the now function.


I don't know if this adds any value to what Jacob Skaria has already
provided, but I got to wondering "what if they delete the entry in column B -
does NDBC want to clear out the date automatically also?" and if you would
want that, I modified his second code offering like this:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, Columns("B:B")) Is Nothing Then
'did the user [Del] contents of cell in B?
If IsEmpty(Target) Then
'yes they did, erase the date also
Target.Offset(0, 1).ClearContents
ElseIf Target.Offset(0, 1).Value = "" Then
Target.Offset(0, 1).Value = Format(Now, "h:mm:ss")
End If
End If
End Sub

if the user simply edits an existing entry in B, the original time remains.
But if they delete the contents of B# then the time is deleted and when they
make a new entry in B#, the new time will be entered into C#.

"NDBC" wrote:

Jacob,

Just tried the first way. It diodn't work for some reason. Just thought I'd
let you know.


"NDBC" wrote:

Jacob,

Thanks, works great. I didn't try the first way but I'm sure it would of
worked as well.

"Jacob Skaria" wrote:

Another way..I hope this is the simpler one

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, Columns("B:B")) Is Nothing Then
If Target.Offset(0, 1).Value = "" Then
Target.Offset(0, 1).Value = Format(Now, "h:mm:ss")
End If
End If
End Sub


If this post helps click Yes
---------------
Jacob Skaria


"NDBC" wrote:

I am using the following code to put the current time in column c when I type
a riders number into column a. What I would like to be able to do is to
change the code so that if there is already a value in column a, I can change
it (like in the case of a typo that needs fixing) I can without the time
getting updated again.

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, Columns("B:B")) Is Nothing Then
Target.Offset(0, 1).Value = Format(Now, "h:mm:ss")
End If
End Sub

Thanks again.

 
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
ISBLANK function not working when cell is blank dut to function re mcmilja Excel Discussion (Misc queries) 9 May 7th 23 03:43 AM
RIGHT function not working Jase Excel Discussion (Misc queries) 1 May 13th 08 09:08 PM
Newly created Get Function is not working when I copied the syntax from a working function CJ Excel Programming 1 January 16th 07 05:28 AM
Working with Arrays, pasing from function to function mikebres Excel Programming 2 April 27th 06 06:33 PM
Function F3 key not working wyattran Excel Worksheet Functions 0 August 8th 05 04:38 PM


All times are GMT +1. The time now is 11:49 PM.

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

About Us

"It's about Microsoft Excel"