Vb Sourcing/Macros Freezing formulas after input

Sammy1994

New Member
Joined
Mar 20, 2017
Messages
12
Hello,

I've been trying to figure something out and currently I am required to use vb sourcing for a solution to my issue.

My issue is trying to freeze a formula which is =IF(A3="","",IF(B3="",NOW(),B3)) after someone places the input into A3.

I need it to freeze so if that user deletes what is in A3 it will not change the date and time, I'm trying to clock input times and secure it from modification. I am not very familiar with VB sourcing or macros, so please be detailed about the solution if there is one.


Thank you,

Sam
 
I have figured out how to lock and only allow VD to input information into Column B.
However, I noticed if a user would have re-input data on column A it changes the time stamp. Which is something I'm trying to avoid. I just want the time stamp to freeze after something was being placed into A no matter what. This is what I have so far


Private Sub Worksheet_Change(ByVal Target As Range)


ActiveSheet.Unprotect Password:="123"
Worksheets("sheet1").Range("B3:B250").Locked = True
ActiveSheet.Protect Password:="123", UserInterfaceOnly:=True



Dim MyRange As Range
Dim cell As Range


' See if update in range A2:A250
Set MyRange = Intersect(Target, Range("A2:A250"))


' Exit if update not in range
If MyRange Is Nothing Then Exit Sub

' Loop through cells in range that were updated
For Each cell In MyRange
' Add timestamp to column B if value in column A
If cell <> "" Then cell.Offset(0, 1) = Now()
Next cell

End Sub

:)
 
Upvote 0

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Try something like this:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    Dim MyRange As Range
    Dim cell As Range

'   See if update in range A3:A250
    Set MyRange = Intersect(Target, Range("A3:A250"))

    If Not (MyRange Is Nothing) Then
'       Loop through cells in range that were updated
        For Each cell In MyRange
'           Add timestamp to column B if value in column A and nothing in column B
            If cell <> "" And cell.Offset(0, 1) = "" Then
'               Update cell in column B
                cell.Offset(0, 1) = Now()
'               Protect cell in column B
                ActiveSheet.Unprotect Password:="password"
                cell.Offset(0, 1).Locked = True
                ActiveSheet.Protect Password:="password"
            End If
        Next cell
    End If

End Sub
 
Upvote 0

Forum statistics

Threads
1,215,411
Messages
6,124,759
Members
449,187
Latest member
hermansoa

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