ActiveX Switching From One Sub to Another

MIdathUK72

New Member
Joined
Apr 7, 2022
Messages
1
Office Version
  1. 2019
Platform
  1. Windows
Hi

I'm trying to use vba to filter different lists on the same spreadsheet - so for example I have a list of departments and the teams within, and the same thing for region and location. I'm using these to create dynamic ranges to populate active x combo boxes - so, select a department then the box for teams only contains relevant teams, and the same for region and location.

Here is my code:

Private Sub ComboBox1_Change()
Sheets("Options").AutoFilterMode = False
Sheets("Options").Range("$G$1:H1").AutoFilter Field:=1, Criteria1:=ComboBox1.Value
Application.DisplayAlerts = True
Sheets("Options").Range("H:H").SpecialCells(xlCellTypeVisible).Copy
Sheets("Working").Range("A1").PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
End Sub

Private Sub ComboBox4_Change()
Sheets("Options").AutoFilterMode = False
Sheets("Options").Range("$p$1:q1").AutoFilter Field:=1, Criteria1:=ComboBox4.Value
Application.DisplayAlerts = True
Sheets("Options").Range("H:H").SpecialCells(xlCellTypeVisible).Copy
Sheets("Working").Range("A1").PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
End Sub

When I make a change to ComboBox1, it then jumps to the ComboBox4 code......

I'm also really confused about the autofilter, in terms of turning it off and on...

Grateful for any help!
M
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Forum statistics

Threads
1,223,880
Messages
6,175,155
Members
452,615
Latest member
bogeys2birdies

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