Board logo

标题: Excel Question re: Time [打印本页]

作者: Elliotbay    时间: 2011-10-8 20:30     标题: Excel Question re: Time

Let's say in cell A5 I want to enter the time when cell A4 has something in it.

The problem is, if(isblank(A4),"",now()), will automatically recalulate the time everytime I press enter or F9. Is there a way to create a static time? Or do I have to automate a copy-paste special - value command and have it automatically run it when a time is entered?
作者: ryanlb    时间: 2011-10-8 20:36

No one? I was really hoping an easy answer existed for this.

I'll just program it in VBA I guess.
作者: malbec    时间: 2011-10-8 20:42

Not sure what you're asking for... you don't want the current time, so what time do you want the cell to show?
作者: segalm    时间: 2011-10-8 20:47

I want the current time when the data is entered. I want this time to remain and not change.



Edited 2 time(s). Last edit at Monday, July 11, 2011 at 07:16PM by kant.
作者: Analti_Calte    时间: 2011-10-8 20:53

This should work:

Right-click the tab > View Code

Then paste this in:

Private Sub Worksheet_Change(ByVal Target As Range)

If Intersect(Target, Range("A4")) Is Nothing Then

Else: Range("A5").Value = Time

End If

End Sub


--------------

Edit: You can replace the word "Time" with either "Now" or "Date" depending on how you want the date/time to read.



Edited 1 time(s). Last edit at Monday, July 11, 2011 at 08:59PM by LukeBBC251.




欢迎光临 CFA论坛 (http://forum.theanalystspace.com/) Powered by Discuz! 7.2