-----Original Message-----
Laura
1/ The code is run not only on pressing of the dropbutton
but also on selection of a value from the list. What can I
use to only run it once?
Use the GotFocus event instead of the click event.
2/ I would like the list do be displayed mid sub so the
value can be selected and used straight away (then I can
continue with the code so the user doesn't have to press
anything else i.e. ShowAllData then refilter for the
category) Currently the list is displayed after the End
Sub.
You can't pause you macro in this way. You need to think of it as
event-driven. What events are happening and what code do you want to run
when they happen. It sounds to me like you want to fill the combobox with
the GotFocus event, then when the user the selects something from the
combobox (the Change event), do your filtering and copying.
3/ I want to use the Cells(x,y) notation rather than Range
("Data!C2:C1000") so that the the list doesn't contain a
lot of blank rows i.e.
Sheets("Front_End").ComboBox1.ListFillRange = Sheets
("Data").Range(Cells(2, 3), Cells(Rownumber, 3)) this
gives an Run-time error 1004 'Application or Object
Defined Error'[Rownumber has just counted the rows which
contain data from filtered list].
I would use the AddItem method to fill the combobox instead of the
ListFillRange. Here's an example that populates a listbox on a userform
with unique values.
http://www.dicks- blog.com/excel/2004/05/using_collectio.html
It will work pretty much the same for a combobox on a sheet. It uses a
collection object to create a unique list from a range, then puts the
collection items in the combobox.
--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com
.