Hi
I am trying to lock an worksheet if a value of over 1M is entered into a specific cell.
Is this possible?
Hi
I am trying to lock an worksheet if a value of over 1M is entered into a specific cell.
Is this possible?
If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
Mark your thread as Solved
If the suggestion helps you, then Click *below to Add Reputation
Hi
Yes I would like to protect the sheet if vale of cell D29 is greater than or equal to 1M.
Thanks so much for your fast reply![]()
Copy the below code and do right click on sheet tab and select view code and paste the below code.
Return to excel and do entry on D29 Cell and check and confirm
![]()
Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address <> "$D$29" Then Exit Sub Dim vValue As Variant On Error Resume Next vValue = UCase(Target.Value) If InStr(1, vValue, "M") Then vValue = Replace(vValue, "M", "") If Len(Target.Value) <> Len(vValue) Then If IsNumeric(vValue) And vValue >= 1 Then Me.Protect "abc" Me.Cells.Locked = True MsgBox "Sheet Protected", vbInformation, "Reached the Maximum Value" End If End If End If End Sub
Hi sorry I did mean 1,000,000 are you able to amend for me? Thanks so much for your help!
Replace the previous code with the below one
![]()
Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address <> "$D$29" Then Exit Sub If IsNumeric(Target.Value) And Target.Value >= 1000000 Then Me.Protect "abc" MsgBox "Sheet Protected", vbInformation, "Reached the Maximum Value" End If End Sub
Sixthsense, I believe OP meant 1,000,000 by 1M, but I could wrong though.
多么想要告诉你 我好喜欢你
@ millz,
Even I am also not sure about the exact keyword about how the OP will enter the values in it.
Just attempted to give solution on assumption.
The questioner should be clear in describing the input values to get exact solution.
We wait and see![]()
@Sixthsense: Very good job on that
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks