VBA - Filter/Un-filter column using Checkbox

Spaztic

New Member
Joined
Jul 27, 2023
Messages
30
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

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
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,215,155
Messages
6,123,331
Members
449,098
Latest member
thnirmitha

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