Sort out data using autofilter

YingFa

Board Regular
Joined
Nov 4, 2019
Messages
63
Hi experts. I currently have the following code (see below) in a worksheet I use at work. I would like to streamline the process to filter data by removing the command button to show all data and include "all" in the combobox. When "all" is selected in the combobox it should filter/show all data. Do you have any idea on how to do this?

Combobox Fill Data

Private Sub ComboBox1_DropButt*******()
Me.ComboBox1.ListFillRange = "Name"
End Sub

Advance Filter

Private Sub ComboBox1_Change()
On Error Resume Next
Sheet1.Range("E2") = Me.ComboBox1.Value
a = Application.WorksheetFunction.CountA(Sheet1.Range("A:A"))
Sheet1.Range("A" & 1, "D" & a).AdvancedFilter xlFilterInPlace, _
Sheet1.Range("E1:E2")
End Sub

Show All Data

Private Sub CommandButton1_Click()
On Error Resume Next
ActiveSheet.ShowAllData
End Sub
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
[FONT=Arial, Tahoma, Helvetica, FreeSans, sans-serif]This should be the first line of the code above
[/FONT]Private Sub Combobox1_DropButt*******()
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,187
Members
452,616
Latest member
intern444

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