ActiveX Checkbox Code for entire column

Adrienne80

New Member
Joined
May 10, 2020
Messages
7
Office Version
  1. 2019
Platform
  1. Windows
I have this code that enables or automatically selects checkboxes based on user selections in the cell in column T. The checkboxes are in 3 separate columns. This works great on checkboxes 1,2, & 3 (on the first line of the worksheet) But it does not work on any line after that. How can I make this code work on any line after this? There are over 100 lines on the worksheet. I've tried many different codes, but can't seem to find any that work. Thanks in advance!

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address(0, 0) = "T17" Then

If Target.CountLarge > 1 Then Exit Sub

If Target.Value = "" Then Exit Sub

Select Case LCase(Target.Value)

Case "prosurance"

Me.CheckBox1.Value = True

Me.CheckBox2.Value = True

Me.CheckBox3.Value = True

Case "care"

Me.CheckBox1.Enabled = True

Me.CheckBox2.Value = False

Me.CheckBox3.Value = False

Case "mi only"

Me.CheckBox1.Enabled = False

Me.CheckBox2.Enabled = False

Me.CheckBox3.Enabled = False

Case "pm only"

Me.CheckBox1.Enabled = False

Me.CheckBox2.Enabled = False

Me.CheckBox3.Enabled = False

Case "assurance"

Me.CheckBox1.Enabled = True

Me.CheckBox2.Enabled = True

Me.CheckBox3.Enabled = True

End Select

End If

End Sub
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
This script will only run if you enter the proper value in Range("T17")
Where else would you like this script to work?
 
Upvote 0
The user can enter values in the T column which has about 150 lines, so T17:T167. I need it to work in all lines, currently it only works on line 17
 
Upvote 0
This should work for any cell in column T after row 16
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Modified  10/13/2020  11:54:00 PM  EDT

If Target.CountLarge > 1 Then Exit Sub
If Target.Value = "" Then Exit Sub

If Target.Column = 20 And Target.Row > 16 Then

  
        Select Case LCase(Target.Value)

            Case "prosurance"
                Me.CheckBox1.Value = True
                Me.CheckBox2.Value = True
                Me.CheckBox3.Value = True

            Case "care"
                Me.CheckBox1.Enabled = True
                Me.CheckBox2.Value = False
                Me.CheckBox3.Value = False

            Case "mi only"
                Me.CheckBox1.Enabled = False
                Me.CheckBox2.Enabled = False
                Me.CheckBox3.Enabled = False

            Case "pm only"
                Me.CheckBox1.Enabled = False
                Me.CheckBox2.Enabled = False
                Me.CheckBox3.Enabled = False
            
            Case "assurance"
                Me.CheckBox1.Enabled = True
                Me.CheckBox2.Enabled = True
                Me.CheckBox3.Enabled = True

        End Select

End If

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,976
Messages
6,122,543
Members
449,089
Latest member
davidcom

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