Vba - Excel ActiveX Combo Box Not Showing Selection - Stack Overflow
Vba - Excel ActiveX Combo Box Not Showing Selection - Stack Overflow
I'm using a ActiveX Combo Box to show all or some Worksheets. In addition to that, on the
same worksheet I have some Form Controls Check Boxes where the user can use them as
0 filters for the Combo Box. So for instance, each check box have the name of department and
so when one is checked the list will be updated with the worksheets related to that name.
Which works fine.
However, the problem I have is that if I do choose an option from the Combo Box drop down
list, it doesn't come up on the field of the Combo Box.
Application.EnableEvents = False
Dim ws As Worksheet
I = 1
TransferList.Clear
If ActiveSheet.Shapes("CheckBox_Viva").ControlFormat.Value = 1 Then
TransferList.AddItem ws.Name
I = I + 1
End If
Next ws
Application.EnableEvents = True
End Sub
I did some research and I did find that by using the TransferList_Change the issue is resolved
but the filtering is not working (no change whether a check box is True or False ).
What am I missing?
Cheers.
Btw, I just started writing the code for the "filtering" so, that is just a first attempt for me to see how it's
working. The reason I used 'TransferList_DropButtonClick' is because the number of worksheets changes
Join StackasOverflow
well as their
to names.
find theIf you
besthave any alternative,
answer smarterquestion,
to your technical way pls feel freeothers
help to share.
– Geo Koro
Sep
Sign up
14,
answer theirs.2021 at 10:26
https://stackoverflow.com/questions/69176062/excel-activex-combo-box-not-showing-selection 1/4
10/21/22, 10:47 AM vba - Excel ActiveX Combo Box not Showing Selection - Stack Overflow
Please, try using the check boxes assigned macro to load the combo. The combo events should be used
for something else...
– FaneDuru
Sep 14, 2021 at 11:15
Hey FaneDuru, not sure what am I suppose to do. I'm not experienced in coding... Could you pls be
more explicit?
– Geo Koro
Sep 14, 2021 at 11:23
So, You should assign a macro (or more) to the check boxes based on which value the combo should be
loaded/filtered. And the combo should be loaded when such a check box will be changed. Now you
said that the check boxes are on the same sheet and I suppose that you do not have all of them
named identic. You should move the code you placed in the combo event, in that sub. And taking care
to use all check boxes I (only) suppose that have to be taken in consideration for a specific loading. You
can know what combo was clicked using Application.Caller , if assign the same Sub to all...
– FaneDuru
Sep 14, 2021 at 11:31
If I should know what you want accomplishing (from the words part...) I can help with a piece of code,
too. But I must confess I do not know what you try doing...
– FaneDuru
Sep 14, 2021 at 11:32
Sorted by:
1 Answer
Highest score (default)
Like I said in my comment I will leave in some minutes. Please, try understanding the next way
of working and extrapolate it at your situation. If something unclear, do not hesitate to ask.
1 But I will be able to answer only after some hours, when I will be at home.
2. Place on the working sheet a combo box (ActiveX type) and so many Form Type check
boxes as workbook number of sheets. Name them (name and caption) exactly as the
sheets, or in a way to make them matching one or some more sheets. Name the combo
as "TransferList".
Sub LoadSheets_Combo()
cmb.Clear
If ActiveSheet.Shapes(ws.Name).ControlFormat.Value = 1 Then
cmb.AddItem ws.Name
End If
Next
End Sub
4. Right click on each check box and choose Assign macro... and choose 'Maros in: This
workbook and at 'Macro name' choose LoadSheets_Combo`.
5. Start paying with check box values and see how the combo is loaded, only with the sheets
matching (somehow) with the ticked check boxes.
https://stackoverflow.com/questions/69176062/excel-activex-combo-box-not-showing-selection 2/4
10/21/22, 10:47 AM vba - Excel ActiveX Combo Box not Showing Selection - Stack Overflow
Please, try the next code able to do what (I understood) you need for your case:
Option Explicit
Sub LoadSheets_Combo()
'ReDim the arrays keeping departments and products at their maximum possible size:
End If
End If
End If
End If
Next
If iD > 0 Then ReDim Preserve arrDep(iD - 1) 'redim the array preserving only the
loaded elements
If iP > 0 Then ReDim Preserve arrProd(iP - 1) 'redim the array preserving only the
loaded elements
boolAllFalse = onlyFalseChkB 'check if all check boxes value is False and place
the result in a boolean var
End If
Else
End If
End If
End If
https://stackoverflow.com/questions/69176062/excel-activex-combo-box-not-showing-selection 3/4
10/21/22, 10:47 AM vba - Excel ActiveX Combo Box not Showing Selection - Stack Overflow
If Not IsError(mtch) Then
arrL = cmb.List
If IsError(mtch) Then
cmb.AddItem ws.Name
End If
Else
cmb.AddItem ws.Name
End If
End If
End If
End If
Next
End Sub
Next
onlyFalseChkB = True
End Function
In order to load the combo according to the above Sub rules when the sheet is activated,
please copy the next code event in the sheet keeping the controls code module:
Option Explicit
LoadSheets_Combo
End Sub
Share Follow edited Sep 17, 2021 at 11:18 answered Sep 14, 2021 at 13:26
FaneDuru
32.8k 4 17 24
Thanks for that. Haven’t had the chance to check it as yet. I’ll get back to you later
– Geo Koro
Sep 15,
2021 at 3:10
@Geo Koro Are there in the active sheet any ActiveX combo box named "TransferList"? I created a test
workbook and it works as it should. Please, download it from here and see it working. Just play with the
three check boxes value and check what is loaded in the combo...
– FaneDuru
Sep 15, 2021 at 16:11
Thank you sooooo much for your time. Is working! Not sure what I did wrong before but I started a new
workbook and it does work. Now I need to work how I'm going to apply multiple filters.
– Geo Koro
Sep 16, 2021 at 3:09
Please, test the new workbook downloading it from here and send some feedback. I downloaded the
previous one on somebody else laptop and transformed it according to my understanding. Please,
confirm that my understanding was correct...
– FaneDuru
Sep 16, 2021 at 6:42
Join Stack Overflow to find the best answer to your technical question, help others
Sign up
answer theirs.
https://stackoverflow.com/questions/69176062/excel-activex-combo-box-not-showing-selection 4/4