Help in code: locked / unlocked based on cell

Sian1

Board Regular
Joined
Nov 9, 2009
Messages
90
Quick question, how could I add when Tier 1 or Tier 2 with cell H13 = "RT - No Insurance" (please note this cell is a drop down list), cell K24:L24 will be locked. Appreciate your help. :)


Private Sub worksheet_change(ByVal target As Range)
If target.Address = "$H$10" Then
If target.CountLarge > 1 Then Exit Sub
ActiveSheet.Unprotect
Select Case target.Value
Case "Tier 1", "Tier 2"
Range("H25:H29").Locked = False
Range("K10:K26").Locked = False
Case "Tier 3", "Tier 4"
Range("H25:H29").Locked = True
Range("K10:K26").Locked = True
Range("H13").Value = "RT with NO RI insurance"
End Select
ActiveSheet.Protect
End If
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Hi Sian1

VBA Code:
Private Sub worksheet_change(ByVal target As Range)
If target.Address = "$H$10" Then
If target.CountLarge > 1 Then Exit Sub
ActiveSheet.Unprotect
Select Case target.Value
Case "Tier 1", "Tier 2"
if Range("H13").Value = "RT - No Insurance" then Range("K24:L24").Locked = True '''added this line
Range("H25:H29").Locked = False
Range("K10:K26").Locked = False
Case "Tier 3", "Tier 4"
Range("H25:H29").Locked = True
Range("K10:K26").Locked = True
Range("H13").Value = "RT with NO RI insurance"
End Select
ActiveSheet.Protect
End If
 
Upvote 0
Hi Sian1

VBA Code:
Private Sub worksheet_change(ByVal target As Range)
If target.Address = "$H$10" Then
If target.CountLarge > 1 Then Exit Sub
ActiveSheet.Unprotect
Select Case target.Value
Case "Tier 1", "Tier 2"
if Range("H13").Value = "RT - No Insurance" then Range("K24:L24").Locked = True '''added this line
Range("H25:H29").Locked = False
Range("K10:K26").Locked = False
Case "Tier 3", "Tier 4"
Range("H25:H29").Locked = True
Range("K10:K26").Locked = True
Range("H13").Value = "RT with NO RI insurance"
End Select
ActiveSheet.Protect
End If
thanks so much :)
 
Upvote 0

Forum statistics

Threads
1,214,808
Messages
6,121,684
Members
449,048
Latest member
81jamesacct

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