+ Reply to Thread
Results 1 to 3 of 3

How to Make a Cell Read only depending upon Value of another cell

Hybrid View

  1. #1
    Registered User
    Join Date
    11-18-2013
    Location
    australia
    MS-Off Ver
    Excel 2010
    Posts
    1

    How to Make a Cell Read only depending upon Value of another cell

    Hello,

    I have 2 Columns in a Excel Sheet. Column A has drop down values and Column B is a free text.

    What I want is that When the user selects a Value in Column A which is less than 2 then the user should not be able to enter anything in Column B, basically the Column B should become read only.
    And maybe I can also display a message to the user that because they entered a value less than 2 they cannot enter anyhting in Column B.

    I am new to Excel so please advice.

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: How to Make a Cell Read only depending upon Value of another cell

    Do right click on sheet tab and select view code and paste the below code. Return to excel and check…

    Private Sub Worksheet_Change(ByVal Target As Range)
    
    If Target.Count > 1 Then Exit Sub
    If Target.Column > 2 Then Exit Sub
    
    If Target.Column = 2 Then
        With Target.Offset(, -1)
            If .Value = "" Or .Value < 2 Then
                Application.EnableEvents = False
                    Target.ClearContents
                Application.EnableEvents = True
                
                MsgBox "Column-A value is less than 2 So Entry is not allowed here...", vbInformation, "Restricted Entry"
            End If
        End With
    Else
        If Target.Value < 2 Then
            Application.EnableEvents = False
                Target.Offset(, 1).ClearContents
            Application.EnableEvents = True
        End If
    End If
    
    End Sub


    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

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: How to Make a Cell Read only depending upon Value of another cell

    Hi and welcome to the forum

    You could also use Data Validation for this, using A as the criteria.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

+ 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. how do you make a cell read only the decimal
    By bansot in forum Excel General
    Replies: 3
    Last Post: 07-01-2013, 01:45 PM
  2. Replies: 4
    Last Post: 10-01-2012, 11:15 AM
  3. Replies: 16
    Last Post: 03-09-2011, 12:27 PM
  4. [SOLVED] how to make cell read only
    By ndalal in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 03-26-2009, 03:52 AM
  5. [SOLVED] How to make a cell read only
    By Little Master in forum Excel General
    Replies: 1
    Last Post: 10-29-2005, 09:05 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