Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default if then statement = time

How do you write an "if' statement that will result in the pc system time.

Ex. IF cell A10, populate A2 with the system time that cell A1 was
populated.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default if then statement = time

You could write an IF statement using =NOW function but that will change
whenever calculation takes place.

You can use CTRL + SHIFT + ; to enter a static time.

Or event code to enter a static time.

The code below will enter a static time in column B when column A is populated
in the range of A1:A10

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("A1:A10")) Is Nothing Then
With Target
If .Value < "" Then
.Offset(0, 1).Value = Format(Now, "hh:mm:ss")
End If
End With
End If
ws_exit:
Application.EnableEvents = True
End Sub

This is event code. Right-click on the sheet tab and "View Code".

Copy/paste the code into that sheet module.


Gord Dibben MS Excel MVP


On Tue, 1 May 2007 12:35:00 -0700, jstaggs
wrote:

How do you write an "if' statement that will result in the pc system time.

Ex. IF cell A10, populate A2 with the system time that cell A1 was
populated.


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4,624
Default if then statement = time

See

http://www.mcgimpsey.com/excel/timestamp.html

In article ,
jstaggs wrote:

How do you write an "if' statement that will result in the pc system time.

Ex. IF cell A10, populate A2 with the system time that cell A1 was
populated.

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
If statement with time Smudge Excel Discussion (Misc queries) 2 January 31st 07 03:15 PM
IF statement to calculate time usage in specific time bands Daren Excel Worksheet Functions 6 January 31st 07 01:34 PM
How to set the time as condition within if statement? Eric Excel Worksheet Functions 2 November 10th 06 01:57 AM
IF Statement help please - again - got it wrong last time! Alan Davies Excel Worksheet Functions 2 May 12th 06 12:28 PM
compare time in IF statement Excel Worksheet Functions 4 July 10th 05 06:18 PM


All times are GMT +1. The time now is 10:54 PM.

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"