+ Reply to Thread
Results 1 to 8 of 8

VBA lock cells based on their content

Hybrid View

  1. #1
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA lock cells based on their content

    Hi Sinon05

    Place this Code in the Sheet Module for Sheet Data...it has some hitches in it's giddyup...see if it works for you.

    Option Explicit
    
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
       Dim LR           As Long
       Dim Comm         As Double
       LR = Range("Q" & Rows.Count).End(xlUp).Row
       If Not Intersect(Target, Range("Q2:Q" & LR)) Is Nothing Then
          Select Case Target.Value
          Case "Please input value"
             On Error Resume Next
             Application.DisplayAlerts = False
             Comm = Application.InputBox _
                    (Prompt:="Please enter Commission.", _
                     Title:="ENTER COMMISSION", Type:=1)
             On Error GoTo 0
             Application.DisplayAlerts = True
             If Comm = 0 Then
                Exit Sub
             Else
                ActiveSheet.Unprotect
                Target.Value = Comm
                ActiveSheet.Protect
             End If
          End Select
       End If
    End Sub
    ***Please Note Well...if this is a Shared File ALL BETS are off...
    Attached Files Attached Files
    Last edited by jaslake; 11-26-2015 at 07:33 PM. Reason: ???Shared File???
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Lock/unlock specific cells in a row based on another cell content of the same row
    By st_rod000 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-10-2014, 02:58 AM
  2. Automatically copy cells content based on the content of another cell.
    By chrisbarlow1984 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-01-2014, 11:13 AM
  3. Replies: 3
    Last Post: 06-28-2012, 09:05 AM
  4. Lock cells based on value of other cells - code simplification query
    By glenin in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-07-2009, 03:11 AM
  5. Lock cells so content or formula can't be changed
    By Rayan83 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-14-2008, 09:01 AM
  6. Lock and clear cell content based on another cell's value
    By mohitmahajanin in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-23-2008, 06:30 AM
  7. Replies: 3
    Last Post: 10-23-2006, 08:57 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1