LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default ListBox and ListIndex

I have two Option Buttons, a ListBox, and two command buttons on a UserForm.
If the user clicks on Optionbutton1, the Listbox populates with certain data.
If the user clicks on Optionbutton2, the Listbox populates with different
data. The user then selects one of the items in the listbox and clicks
"Continue" (command button). After clicking the command button, the program
sends the user to a specific Sheet.

I am having a problem with:
When the user clicks on Optionbutton2 the Listbox populates fine, however it
does not send the user to the correct sheet after he/she clicks "Continue". I
think I am doing this right and I cannot figure out what is wrong. Any help
would be greatly appreciated. My code follows below.
_______________________

Private Sub CommandButton4_Click()
' Stores the selection from the Listbox to allow the user to continue to
the correct pipe type.

If Me.ListBox1.ListIndex = 0 = True Then
Worksheets(48).Activate
UserForm12.Hide

ElseIf Me.ListBox1.ListIndex = 1 = True Then
Worksheets(49).Activate
UserForm12.Hide

ElseIf Me.ListBox1.ListIndex = 2 = True Then
Worksheets(50).Activate
UserForm12.Hide

ElseIf Me.ListBox1.ListIndex = 3 = True Then
Worksheets(51).Activate
UserForm12.Hide

ElseIf Me.ListBox1.ListIndex = 4 = True Then
Worksheets(52).Activate
UserForm12.Hide

ElseIf Me.ListBox1.ListIndex = 5 = True Then
Worksheets(68).Activate
UserForm12.Hide

ElseIf Me.ListBox1.ListIndex = 6 = True Then
Worksheets(69).Activate
UserForm12.Hide

ElseIf Me.ListBox1.ListIndex = 7 = True Then
Worksheets(70).Activate
UserForm12.Hide

ElseIf Me.ListBox1.ListIndex = 8 = True Then
Worksheets(71).Activate
UserForm12.Hide

ElseIf Me.ListBox1.ListIndex = 9 = True Then
Worksheets(72).Activate
UserForm12.Hide
End If
End Sub
Private Sub OptionButton1_Click()
Me.ListBox1.Clear
With Me.ListBox1
.AddItem "A", Index = 0
.AddItem "B", Index = 1
.AddItem "C", Index = 2
.AddItem "D", Index = 3
.AddItem "E", Index = 4
End With

End Sub
Private Sub OptionButton2_Click()
Me.ListBox1.Clear
With Me.ListBox1
.AddItem "A", Index = 5
.AddItem "B", Index = 6
.AddItem "C", Index = 7
.AddItem "D", Index = 8
.AddItem "E", Index = 9

End With

End Sub

--
Message posted via http://www.officekb.com
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
combo box and .listindex dirt Excel Programming 3 September 10th 04 03:01 AM
listbox listindex problem jacob Excel Programming 2 August 25th 04 08:46 AM
listindex Steph[_3_] Excel Programming 1 June 25th 04 06:14 PM
ListIndex Todd Huttenstine Excel Programming 2 May 13th 04 04:21 PM
listbox.value not equal to listbox.list(listbox.listindex,0) ARB Excel Programming 0 October 22nd 03 12:46 AM


All times are GMT +1. The time now is 11:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"