This is the forum to discuss the Wrox book Excel 2003 VBA Programmer's Reference by Paul T. Kimmel, Stephen Bullen, John Green, Rob Bovey, Robert Rosenberg, Brian Patterson; ISBN: 9780764556609
You are currently viewing the BOOK: Excel 2003 VBA Programmer's Reference section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
Complete details: Filter worksheet as per validation listbox selection
I have copied data from excel sheet.
Country
Nepal <- Select a country from the Validation Listbox.
Country aa bb cc
India 34 56 78
Nepal 45 67 86
US 34 44 45
India 23 33 34
Nepal 44 56 66
US 77 77 88
India 65 56 77
Nepal 33 34 45
India 88 87 77
Nepal 33 57 78
Above lists should get filtered as per selection made in the Validation listbox shown on Top row.
Thanks mtranchi,
Its working fine but I need one more help please.
How, I can run macro automatically when value is changed in Validation listbox, and also it should display entire records when ALL is selected from the listbox.
Thanks in Advance.
Aalok
Last edited by aalokwar; October 27th, 2010 at 03:36 AM.
Reason: To Add one more query
when you're in design mode, double click the list box and it should bring you to the listbox change event. put the code in there.
Should look something like this
Code:
Sub Listbox1_Change() 'Where Listbox is whatever you named it
Sheets("sheet1").Range("dataset").AutoFilter
ActiveSheet.Range("$A$3:$C$13").AutoFilter Field:=1, Criteria1:=textbox1.Text
End Sub
Oh, to make it show all, just use the autofilter again without any parameters
Code:
ActiveSheet.Range("$A$3:$C$13").AutoFilter
'something like that, but the proper sheet and range
i should say though that it sounds like you maybe reinventing the wheel. The autofilter function does exactly what you're doing and no need to write code.
Don't know what version of excel you have, pre 2007 i think autofilter is under Data. 2007 and 2010 it's on the Data tab.
Hope that helps
take care
Never thought of trolling the VBA forums for cuties. I am very much attracted to females with good minds, math skills and analytical abilities a plus, lol
The Following User Says Thank You to mtranchi For This Useful Post:
Jeez, guess I'm gonna sound pathetic here, but...
Yes, ugh, I'm single at the moment. It seems like every girl i come across hates math or sucks at it.
I guarantee this:
You will find me attractive physically.
I have a sense of humor you will love.
I put the toilet seat down (only if there's a woman in the house though).
I've stood tall against virtually all threats i've had to deal with in life. No, I'm not the baddest ass, but I'll scare away most with a mere look.
I am trainable.