Formula or VBA to stop the NOW function

Sparky

Board Regular
Joined
Feb 18, 2002
Messages
210
Office Version
  1. 2010
Platform
  1. Windows
I have the NOW function in cell A1
In cell A2 the time is entered manually
In cell A3 I have A1-A2 to display the amount of time elapsed
In cell A4 I would like to be able to enter the letter C once a task has been completed in my work place and once the letter C has been entered the time elapsed would then remain static.

Thanks in advance
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Try this. Right click the sheet tab and select View Code then paste in

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 4 And UCase(Target.Value) = "C" Then
    Application.EnableEvents = False
    Target.Offset(0, -3).Value = Now
    Application.EnableEvents = True
End If
End Sub

then close the code window using the X.
 
Upvote 0
Thanks for your quick reply.

I have pasted your code as you suggested but the time elapsed in A3 continues to increase as the minutes go by every time the sheet is recalculated.
 
Upvote 0
Sorry, I had confused rows with columns :oops:

Try this

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row = 4 And UCase(Target.Value) = "C" Then
    Application.EnableEvents = False
    Target.Offset(-3, 0).Value = Now
    Application.EnableEvents = True
End If
End Sub
When you enter C (or c) in row 4 the NOW() formula in row 1 will be replaced by a static Now.
 
Upvote 0
It worked OK the first time and the NOW function remained static. But somehow it no longer works.
 
Upvote 0
Press ALT+F11 to open the Visual Basic Editor. Press CTRL + G to open the Immediate Window. Type in

? application.enableevents

and press Enter. Does that return False? If so type

Application.EnableEvents = True

and press Enter. Then close the code window and test whether the event code is now working.
 
Upvote 0

Forum statistics

Threads
1,214,622
Messages
6,120,585
Members
448,972
Latest member
Shantanu2024

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top