Static timestamp

harbour1302

New Member
Joined
Jun 13, 2017
Messages
25
Hi guys,

First time posting here, i am stuck with a timestamp issue i want B10 to update with a timestamp whenever text is entered into B57 and to show empty when B57 is empty or cleared.

I originally used the formula =IF(ISTEXT(B57),NOW(),"")
However the time updates whenever the sheet is reopened or F9 is pressed.

I require the time to be static, i have researched VBAs but cannot find the correct one.

Can anyone help i am using excel 2016.
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Welcome to the Board!

That is because the formula always returns the current date/time. You need to use VBA.

Right-click on the sheet tab name at the bottom of your sheet, select View Code, and paste this code in the resulting VBA window:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    If Target.Address(0, 0) = "B57" Then
        If Target = "" Then
            Range("B10").ClearContents
        Else
            Range("B10") = Now()
        End If
    End If
        
End Sub
This is automated VBA code that runs whenever cell B57 is updated.
 
Last edited:
Upvote 0
You are welcome!
Glad I was able to help!:)
 
Upvote 0
Hi,

I am now getting an Application-defined or object-defined error.

I believe this is due to the worksheet being protected.

Is there a way to unprotect to allow code to run and reprotect at the end or bypass lock and run code?

Thanks
 
Upvote 0
Just start out unprotecting the sheet and then re-protect it at the end, i.e.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    If Target.Address(0, 0) = "B57" Then
        ActiveSheet.Unprotect "password"
        If Target = "" Then
            Range("B10").ClearContents
        Else
            Range("B10") = Now()
        End If
        ActiveSheet.Protect "password"
    End If
        
End Sub
Substitute "password" with your password.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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