Enable/Disable Cell if another cell has an especific text

mariopaz18

New Member
Joined
Mar 5, 2014
Messages
3
Hello All,

I am trying to have lets say: if the cell A1 has "Solicitud" in it then the cel B1 should be enable for imput (I actually have the cel B1 validated with a Yes/No list) but if the cel A1 is blank or it does not have "Solicitud" then B1 cel should be disabled for editing.

VBA code or formulas accepted.

Thank you very much for your prompt help.
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Hi mariopaz. Start by formatting the protection for A1 and B1 as 'unlocked'. Next protect the worksheet. Try this macro:
Code:
Sub Test()
    ActiveSheet.Unprotect
    If Range("A1") = "Solicitud" Then
        Range("B1").Locked = False
    Else
        Range("B1").Locked = True
    End If
    ActiveSheet.Protect
End Sub
 
Upvote 0
Hi mariopaz. Start by formatting the protection for A1 and B1 as 'unlocked'. Next protect the worksheet. Try this macro:
Code:
Sub Test()
    ActiveSheet.Unprotect
    If Range("A1") = "Solicitud" Then
        Range("B1").Locked = False
    Else
        Range("B1").Locked = True
    End If
    ActiveSheet.Protect
End Sub

--------------
Thank you, one more question, I want this for an especific range of cels in the A column and the locked function in the same range of cels in the B column....
 
Upvote 0
Try:
Code:
Sub Test()
    ActiveSheet.Unprotect
    Application.ScreenUpdating = False
    Dim LastRow As Long
    LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Dim rng As Range
    For Each rng In Range("A2:A" & LastRow)
    If rng = "Solicitud" Then
        Range("B" & rng.Row).Locked = False
    Else
        Range("B" & rng.Row).Locked = True
    End If
    ActiveSheet.Protect
    Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,999
Messages
6,128,196
Members
449,432
Latest member
Novice Excel User

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