ListBox Execution

  • Thread starter Carrie_Loos via OfficeKB.com
  • Start date
C

Carrie_Loos via OfficeKB.com

Hi - I have created a userform(multi) with a ListBox (Multiple Lists) on a
tab and I am now stuck. What I need to do is when the user selects a choice
in one of the listboxes I want it to go to a sheet named "Classes" and select
the appropriate column and value, from the listbox, and apply it to the
filters I have so that only that item appears on the sheet. I have gotten as
far as below with the 'MsgBox "True" and MsgBox "False' as place holders but
I cannot figure out how to write the filter portion....[In this case the
Unique_Class_ID is in column E] Can anyone help?

Thanks
Carrie

Dim ctrl As Control
ListBox1.RowSource = "CLasses!Unique_Class_ID"

Select Case ListBox1.ListIndex
Case -1
MsgBox "True"
Case Else
MsgBox "False"
End Select

For Each ctrl In UserForm1.Controls
If TypeOf ctrl Is MSForms.TextBox Then
ctrl.Value = ""
ElseIf TypeOf ctrl Is MSForms.OptionButton Then
ctrl.Value = False
End If
Next ctrl
 
J

Jim Cone

Try recording a macro while you filter the sheet.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)




"Carrie_Loos via OfficeKB.com"
wrote in message
Hi - I have created a userform(multi) with a ListBox (Multiple Lists) on a
tab and I am now stuck. What I need to do is when the user selects a choice
in one of the listboxes I want it to go to a sheet named "Classes" and select
the appropriate column and value, from the listbox, and apply it to the
filters I have so that only that item appears on the sheet. I have gotten as
far as below with the 'MsgBox "True" and MsgBox "False' as place holders but
I cannot figure out how to write the filter portion....[In this case the
Unique_Class_ID is in column E] Can anyone help?
Thanks
Carrie


Dim ctrl As Control
ListBox1.RowSource = "CLasses!Unique_Class_ID"
Select Case ListBox1.ListIndex
Case -1
MsgBox "True"
Case Else
MsgBox "False"
End Select

For Each ctrl In UserForm1.Controls
If TypeOf ctrl Is MSForms.TextBox Then
ctrl.Value = ""
ElseIf TypeOf ctrl Is MSForms.OptionButton Then
ctrl.Value = False
End If
Next ctrl
 
C

Carrie_Loos via OfficeKB.com

Yes, thanks, I did try that without success. And after all I have been
reading in help and other books that I have, I am beginning to wonder if you
can't select a value out of a list box?
 
J

Jim Cone

Dim strSomething as String
strSomething = Me.ListBox1.Value
Worksheets("Stuff").Range("B5").Value = strSomething
'--
With a multi-select listbox you have to run a loop.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)


"Carrie_Loos via OfficeKB.com"
wrote in message
Yes, thanks, I did try that without success. And after all I have been
reading in help and other books that I have, I am beginning to wonder if you
can't select a value out of a list box?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top