VBA - Filter/Un-filter column using Checkbox

Spaztic

New Member
Joined
Jul 27, 2023
Messages
48
Office Version
  1. 365
Platform
  1. Windows
Hi! I'm looking for vba code for the following.

I want to have a Check Box where the following occurs:
Checked: Filters entire column C looking for 'X'
Unchecked: Removes filter in column C

Is this something that can be done? Appreciate any help in advance!

1701877358830.png
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Please try the following. Put the code in a standard module. Then right-click the check box - select Assign Macro and assign this macro to the check box.
VBA Code:
Option Explicit
Sub Filter_If_Checked()
    Dim cx As Excel.CheckBox
    Set cx = ActiveSheet.CheckBoxes(Application.Caller)
    If cx.Value = xlOn Then
        Range("C:C").AutoFilter 1, "X", , , 0
    Else
        ActiveSheet.AutoFilterMode = False
    End If
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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