ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   ListBox Execution (https://www.excelbanter.com/excel-programming/406209-listbox-execution.html)

Carrie_Loos via OfficeKB.com

ListBox Execution
 
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

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200802/1


Jim Cone

ListBox Execution
 

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


Carrie_Loos via OfficeKB.com

ListBox Execution
 
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?

Jim Cone wrote:
Try recording a macro while you filter the sheet.


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200802/1


Jim Cone

ListBox Execution
 

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?

Jim Cone wrote:
Try recording a macro while you filter the sheet.


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200802/1



All times are GMT +1. The time now is 08:06 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com