Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 354
Default Static current date based on when data in another column was enter

I want to setup a date column that each cell in the date column reflects the
date that another column in the same row was filled in.

Example: I enter a numerical value in cell D5 that is greater than 0. I want
A5 to record the date that I entered that data.

Also I would like to do the same thing with time in cell B5. How could I do
this?

Thanks a lot!
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,058
Default Static current date based on when data in another column was enter

Place the following event macro in the worksheet code area:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim d5 As Range, t As Range
Set d5 = Range("D5")
Set t = Target
If Intersect(t, d5) Is Nothing Then Exit Sub
If Not IsEmpty(Range("A5")) Then Exit Sub
Application.EnableEvents = False
Range("A5").Value = Date
Range("B5").Value = Time
Application.EnableEvents = True
End Sub


Because it is worksheet code, it is very easy to install and use:

1. right-click the tab name near the bottom of the window
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window

If you save the workbook, the macro will be saved with it.

To remove the macro:

1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

To learn more about Event Macros (worksheet code), see:

http://www.mvps.org/dmcritchie/excel/event.htm


--
Gary''s Student - gsnu200909


"Daniel" wrote:

I want to setup a date column that each cell in the date column reflects the
date that another column in the same row was filled in.

Example: I enter a numerical value in cell D5 that is greater than 0. I want
A5 to record the date that I entered that data.

Also I would like to do the same thing with time in cell B5. How could I do
this?

Thanks a lot!

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,069
Default Static current date based on when data in another column was enter

You can do that with a Worksheet_Change event:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Columns("D")) Is Nothing Then
If Len(Target.Value) 0 And Target.Value 0 Then
Target.Offset(0, -3).Value = Date
Target.Offset(0, -2).Value = Time
End If
End If
End Sub

This code must be in the code module for the sheet where it should work.
Right-click on that sheet tab and select View Code. The Visual Basic Editor
will be displayed. Paste the above code in the big empty code window. Select
File Close to return to regular Excel.

If you are new to macros, this link to Jon Peltier's site may be helpful:
http://peltiertech.com/WordPress/200...e-elses-macro/

Hope this helps,

Hutch

"Daniel" wrote:

I want to setup a date column that each cell in the date column reflects the
date that another column in the same row was filled in.

Example: I enter a numerical value in cell D5 that is greater than 0. I want
A5 to record the date that I entered that data.

Also I would like to do the same thing with time in cell B5. How could I do
this?

Thanks a lot!

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 35,218
Default Static current date based on when data in another column was enter

Just a suggestion...

Put the date and time in one cell:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

Dim myCell As Range
Dim myRngToInspect As Range
Dim myIntersect As Range

Set myRngToInspect = Me.Range("D1").EntireColumn

Set myIntersect = Intersect(Target, myRngToInspect)

If myIntersect Is Nothing Then
Exit Sub 'outside of column D
End If

For Each myCell In myIntersect.Cells
Application.EnableEvents = False
With Me.Cells(myCell.Row, "B")
.NumberFormat = "mm/dd/yyyy hh:mm:ss"
.Value = Now
End With
Application.EnableEvents = True
Next myCell

End Sub

If you want to try, rightclick on the worksheet tab that should have this
behavior. Select view code and paste this into the newly opened code window.

Then back to excel to test it.

Daniel wrote:

I want to setup a date column that each cell in the date column reflects the
date that another column in the same row was filled in.

Example: I enter a numerical value in cell D5 that is greater than 0. I want
A5 to record the date that I entered that data.

Also I would like to do the same thing with time in cell B5. How could I do
this?

Thanks a lot!


--

Dave Peterson
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
How to add todays date (static) to the current active cell using m JimmyJam75 Excel Discussion (Misc queries) 5 September 6th 06 11:23 AM
how do I insert the current time (static) and date in a cell? DF Excel Discussion (Misc queries) 5 October 28th 05 05:54 PM
Can I automatically enter the current date or current time into a Ben New Users to Excel 7 October 19th 05 03:38 PM
How to enter current static time in Excel in 00:00:00.0 format? Wlumkong Excel Worksheet Functions 3 May 12th 05 03:54 PM
Excel static current date/time problem hpmted Excel Worksheet Functions 1 March 30th 05 09:12 PM


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