Activex Combobox Not Selectable After Rows Unhidden - excel

I have searched for a while now and dont see a solution to my issue. I have several activex comboboxes on a worksheet. For instant there are 5 Comboboxes in rows 1-5. The user clicks a button that is linked to a userform which will hide or unhide the 5 rows based on the users input. Hidding the 5 rows is not issue using vba. The problem that I am facing is when the 5 rows are unhidden, the comboboxes are non-selectable. What i mean is the user cant select or begin typing anything into them. They are visible but almost like an invisible object is over them so a user cannot select them.
Making a copy of the worksheet or selecting "design mode" and moving the boxes slightly, the comboboxes are selectable again. I dont want to keep copying sheets and I haven't found a way to move the comboboxes accurately outside of design-mode. Below is vba code I was trying to use to move the box but using -11 and 11 would just move the box up both times.
Anyone know why activex comboboxes get "locked" after they rows they are in become unhidden or have a solution?
ActiveSheet.Shapes("ComboBox1").IncrementTop 11

I had the exact same issue, using Excel 2019.
I don't know the cause, but I found a workable solution.
First, to also declare my specific problem:
I have a drop-down activex list, through which if "Option 1" is chosen, it hides many rows as well as ComboBox1 , but if "Option 2" is selected, then it shows these rows and the Combobox1.
So, when "Option 2" is called after "Option 1", the desired rows are visible, while ComboBox1 is visible but unselectable.
My solution is that I added a positional statement in the drop down list's code, in case of "Option 2" selected. As following:
ComboBox1.Top = 75 # or wherever you want it to be (trial&error)
ComboBox1.Left = 410 # or wherever you want it to be (trial&error)

Related

Clear contents of hidden excel cells based on dropdown menu vba

I am looking to clear a set of cells (reset them) every time a new option is selected in the dropdown menu. However, based on the choice selected, a different combination of rows will be hidden. There are 12 of these dropdowns and so I need a function I can call that will clear only the cells related to that drop down (when all are unhidden there are 16 rows and 3 columns). I have tried using the formula below, however it does not recognize the hidden rows and ends up deleting the contents of the following dropdown's rows. Thank you in advance for your help.
Sub Clear(Target As Range)
Range(Target.Offset(16,).Address, Target.Offset(,3).Address).Value = " "
End Sub

Getting Values from Multiple Comboxes in same sub

I have an excel sheet workbook with 2 sheets. One sheet has data imported from an external source and the other sheet then filters this data. I want to be able to select a date range to narrow done the filtered results.
To do this, I have 4 comboboxes, one checkbox, and one button. When the button is clicked I want my sub to first see if the checkbox has been checked. If it has not, then just run filter the data regardless of date. If the checkbox is checked, I then want to look at the four comboboxes. The first two will have the start year and start month and the last two will have the end year and end month. I want to take these values and filter my data using this criteria as well when the checkbox has been checked.
The issue I am having is that I cannot get the value of the combobox. For example, I named one of my comboboxes "Start_Month". In my sub, when I select the sheet with the combobox first, then I use "Start_Month.Value" to check the combobox value, but this gives me runtime error 424 "Object Required".
Does anybody know how to get the value of four different comboboxes in the same sub or is this not possible?

How to populate ComboBoxes from ListBox selection?

So I have a UserForm that has a ListBox and ComboBoxes.
I also have a button above the ListBox that when clicked, the data from the spreadsheet will be displayed.
If I clicked the value from the ListBox, it will be automatically displayed on the ComboBoxes below per column.
Say the value from the Schema column from the ListBox says "ABC", "ABC" will also be displayed on the ComboBox below it. It is the same with the other ComboBoxes.
Is there a possible way to do it?
I've been looking for answers but none of the methods have worked on me and I couldn't find any similar problems. Please help :(
You need to create a sub on Click event and then select one by one the columns
Private Sub <ListBox>_Click()
<ComboBox>.Value = <Userform>.<ListBox>.Column(0)
End Sub
Replace the < name > with the actual name of your objects
But as PEH said, I see no reason why this case would be a ComboBox, you may want to consider changing it for a TextBox

Can't use more than one combo box on excel

I have made two active X combo boxes for a list of 220 sites. Before making the active x combo box i have made a sheet that searches through my data and finds the sites that match with what i am typing as i go.
I then used the name manage, refering to the formula in the first cell of the list
=Sheet1!$G$2:INDEX(Sheet1!$G$2:$G$220,COUNTIF(Sheet1!$G$2:$G$220,"?*"))
I have then writen this in the ListFillRange in the properties of my combo box.
It works fine for one, but once i had made the second one and selected the site the first one will no longer let me search through.
I have used the same formulas on both but they originate from different sheets to see if this fixed the problem however that was unsuccessful. (the boxes are on different sheets) When i click on the next sheet after using the box on the first sheet, it still shows part of it as if it is crashing.
The boxes are independent so I'm not sure what to do next as i need to add another 3 on separate sheets.
I am also using this code for each box
Private Sub ComboBox1_Change()
ComboBox1.ListFillRange = "MList"
Me.ComboBox1.DropDown
End Sub
and similar for the other button but with a different range.
There is no need to use VBA for this, the Change Events specifically, if you just want to use and fill the combo boxes with Named Ranges.
The scenario I think you try to do is:
Create Named Ranges that will be the source of your combobox:
Fill the range with your data, select the range, Right Click, Select Define Name and give the range a name. MList in your case I believe.
Create Combobox:
Goto Developer Tab, Insert in your case ActiveX ComboBox, Draw it on your sheet, right click the ComboBox, select properties, find ListFillRange in properties and enter the name of the Named Range you created in step one
Repeat for Combobox 2, with the same or a different Named Range depending on what you try to do
Leave Design Mode
Boths Comboboxes can now be used to type in what you are looking for.
If this is not what you tried to do, please try edit your question and in detail try to explain what you try to do and what you like to accomplish by doing so.

Dynamically Populate Listbox - Exclude Empty cells

I am creating a form in excel (not a userform) and I am populating the listbox using cells. However, these cells are sometimes A1:10 and sometimes they are A1:A4. Is there a way to dynamically change what is shown in the listbox?
Right now, when I use A1:10 and there are only 4 cells populated, I get the list of 4 populated cells followed by 6 blank entries. I'd like to get rid of the 6 blanks when there are only 4.
Unfortunately, this is more of a workaround than a solution. However, it may be able to do what you need it to do. I've been hitting the same wall you are with trying to make ranges dynamic.
Without seeing some code to know exactly what you're doing, try something like this.
Private Sub ListBox1()
x = 1
'Add items to listbox until you reach an empty cell.
Do while Cells(x,1) <> ""
ListBox1.AddItem Cells(x,1)
Loop
I'm not very familiar with listboxes outside of userforms but this should do approximately what you want to do.
Edit your original post with your code so we can try and get a better understanding of what you've tried and what you're trying to do.
You can create a named range using a dynamic formula. Either of the below formulas will work.
=A1:INDEX($A$1:$A$10,MATCH("",$A$1:$A$10,0)-1)
=OFFSET($J$7,0,0,MATCH("",$J$7:$J$32,0)-1)
To create the named range, click ctrl+F3 then click new, insert one of the two options above into the "refers to:" section, then label the new range whatever you would like. in the "row source" section of the listbox simply type in the name you selected for your new named range.

Resources