#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,058
Default Date functions

First entered I guess means if the data changes leave the first date in.
Here is an example for data entered in column A. Dates are automatically
entered in column B:


Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Range("A:A"), Target) Is Nothing Then
Exit Sub
End If
If IsEmpty(Target.Offset(0, 1)) Then
Application.EnableEvents = False
Target.Offset(0, 1).Value = Now()
Application.EnableEvents = True
End If
End Sub


This is worksheet code and does not go in a standard module.
--
Gary''s Student
gsnu200712

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 6
Default Date functions

Now having had a chance to look at this a little closer, I am coming to the
conclusion it is not what I was hoping it might be. It's a macro and
therefore not something I can run from within a cell (as I understand the
help documentation).
I was looking for a custom function and I know next to nothing about VBA, so
am unsure how to make this into one, if it can be made into one at all. I've
tried changing 'Sub' into 'Function' but it does do it for me.
The good news is that you have given me a much better idea as to how to
start. For instance, providing I don't try to use a range, the guts of the
macro work very well in a cell as an IF() statement, e.g. IF (C2<"", NOW(),
""). I now just need to understand how to make it work with a range of
target cell values. I've tried IF (C2:H2<"", NOW(), "") and also IF (C2<""
AND B2<"" AND... etc, NOW(), "")but this doesn't work - obvious to you,
perhaps, why, but not yet to me...



"Gary''s Student" wrote:

This version will work with any cell, not just cells in column A
This version works with mutiple cells, so copy/paste will record the date
for an entire block of cells:


Private Sub Worksheet_Change(ByVal Target As Range)
For Each r In Target
If IsEmpty(r.Offset(0, 1)) Then
Application.EnableEvents = False
r.Offset(0, 1).Value = Now()
Application.EnableEvents = True
End If
Next
End Sub

--
Gary's Student
gsnu200712

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,058
Default Date functions

This version will work with any cell, not just cells in column A
This version works with mutiple cells, so copy/paste will record the date
for an entire block of cells:


Private Sub Worksheet_Change(ByVal Target As Range)
For Each r In Target
If IsEmpty(r.Offset(0, 1)) Then
Application.EnableEvents = False
r.Offset(0, 1).Value = Now()
Application.EnableEvents = True
End If
Next
End Sub

--
Gary's Student
gsnu200712

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
Date Functions mark.nelson4 Excel Worksheet Functions 7 January 3rd 07 10:47 PM
IF and Date Functions Christ4 Excel Worksheet Functions 3 August 11th 06 04:18 AM
Date Functions Keith Excel Discussion (Misc queries) 2 April 24th 06 06:43 PM
Date functions John New Users to Excel 3 August 15th 05 08:50 PM
Date functions Kirk P. Excel Discussion (Misc queries) 2 April 6th 05 05:36 PM


All times are GMT +1. The time now is 04:04 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"