I am aware that this thread already exists:
Hide DropDown list for ComboBox without losing focus
But unfortunately, it is for a UserForm and isn't applying to my questions.
My situation is rather on a Worksheet like below:
In fact, to show that dropdown list, here is what I did:
shLedgerImport.CboAcctCode.DropDown 'This function shows the dropdown list
But once it appears, I cannot hide it anymore:
---> I just want it to hide that dropdown list when I click on E2, of H5 or anywhere except E9 that is the ActiveCell.
(In case the user displayed it by mistake and want it to hide, what they need to do? Escape key isn't working, Click elsewhere isn't working)
Thank you
Related
I am trying to figure out if it is possible to check or uncheck a checkbox based on a value in a cell.
I have a userform that gets filled out and adds new lines on a worksheet with the relevant information gathered from the userform. I want to be able to search for a particular entry and fill out a neat created form on a excel worksheet (not a userform) using the gathered information. In this form I want to use checkboxes instead of cells to keep it neat and professional.
The reason I am doing this into a worksheet form instead of a userform is to be able to print the form into a PDF document. As far as I am aware it is not possible to print a userform into a PDF document.
If it is working the worksheet form should have checkboxes checked if TRUE is found in the cell from that particular data entry. I can't link a specific cell since it needs to find the correct cell based on the search entry.
Following on the comments... #Tom is correct, you can simply link the combobox to the cell in question.
Insert combobox:
Then simply enter the cell reference in the formula bar you want to link it to. Namely:
I have made a userform using macros in excel.
The code is independent from excel (it does not read the data from excel).
Once the userform opens, I populate the combobox with few items in it by:
combo.additem "a"
combo.additem "b"
combo.additem "c"'
From what I found, in order to make the combobox uneditable, I need to change the style of the list to drop downlist.
However, once I have done so, my combobox options turns to be:
"" (blank cell)
a
b
c
Is there an option to keep the combobox uneditable without adding the first empty cell?
Thank you
The combobox will become an uneditable dropbox when you change its Style to 2 - fmStyleDropDownList.
Add .ListIndex=0 to your code to make the dropbox come up with no empty field and have the first item displayed as the default.
I'm wanting to have a an excel spreadsheet automatically fill in a dropdown selection based on a previous dropdown.
Basically i have a spreadsheet that allows me to pick colours of items from basic dropdown lists each row has its own dropdown. Often the colours are the same so would like it to automatically fill in the next rows colour the same as the previous lines for me?
anyone have any ideas? Can't seem to find much on only filling out the dropdown? Also is there a method to fill out all dropdowns simultaniously?
Thanks
There are two approaches to this depending on what you mean by 'drop-down'.
If you are using a 'form control' drop-down then you have the option under right-click>Format Control... to specify a cell whose value will be set when you change the drop-down selection. You can then use this value to affect other areas of your spreadsheet.
If your drop-down is done using the 'Data Validation' then it will only affect the cell you have put it in. In this case you will have to turn to VBA.
For this you would use the Worksheet_Change event and an If statement checking that the Target is the drop-down cell, then you can code the filling in of your other dropdowns. Check out this microsoft guide for triggering VBA from cell changes.
I'm working out a dashboard for my office. It all works, but I wanted to add in an option that instead of searching through 250+ items in a dropdown, you could also click on a cell and the dropdown would change to that value, and the assigned macro would run for that dropdown. So far I can't figure out how to have vba select a specific item from a dropdown. I can have the text change, but that doesn't select the index of the dropdown.
Any suggestions?
If you are using an ActiveX drop down list, (a combobox) this is how you would change the selected value in the drop down list:
ComboBox1.Value = "New Value"
If you are using data validation as a drop down list, then you just need to change the cell value as you would change any other cell:
'assuming the drop down list (data validation) is in Cell(1, 1)
cells(1,1) = "New Value"
Also you could check this article I've written on my blog about working with drop down lists in VBA Excel VBA Drop Down Lists
I wanted to do the same: Select an option from several drop down lists, then "reset" all of them to a starting point. Recording a macro and change the drop down list wont work.
However, I did the following:
Start recording macro
I typed all the values I wanted to be the "starting point once reset on the drop down list
stop macro.
It worked. Now I hit the macro and I get all the values "reset". Cheap trick, I know but worked for me.
Is it possible to have a macro that, when pressed, pops up a message box asking for a string of text, and then a drop down that has a list of categories?
All I would need it to do is take this information and save it into a cell. If so, how?
[I'm going based on Excel 2007 here, but if you're using 2003, you'll have to navigate the menu structure]
Go to the VBE (by going to the View tab, then click on Macro - creating or editing an existing one will take you there - or click Alt+F11).
Go to the Insert menu, and select Userform. Drag a textbox (the ab|icon), and a combobox onto your form. To set the textbox value to a cell when you change the combobox, create a subroutine in the code to do this by double clicking on the combobox.
Set the combobox items by using the .additem method of comboBox1 in your code. These can be delineated or grabbed from a range in your code (see here)
Within that subroutine, set the value of whatever cell you want to textbox1.Text, which is the contents of the textbox.