Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default ComboBox Problems

Hi everyone,
I made a userform that has some option buttons and two comboboxes. The user
choses from the two groups of option buttons and then goes to the first
combobox. I want the information in the second combobox to change depending
on what the person choses from the first combobox. I am having some problems.
It works well the first time but if the user changes their mind (i.e. choses
something else in the first combobox) the second combobox does not respond.
It clears and no new information is put in
Here is my code

COMMANDBUTTON3 ACTIVATES THE CHANGING OF COMBOBOX2, DEPENDING ON COMBOBOX1
INFORMATION

Private Sub CommandButton3_Click()
If Why.ComboBox1.Text = "-KAJ" Then
Why.ComboBox2.Clear
'Filling second combobox
Dim j As Integer
j = 2
Do Until IsEmpty(Cells(4, j))
prod = Workbooks("specs.xls").Worksheets("ProductIdentity ").Cells(4, j)
Why.ComboBox2.AddItem (prod)
j = j + 1
Loop
ActiveWorkbook.Sheets("Blank").Select
End If
If Why.ComboBox1.Text = "-AA" Then
'Filling second combobox
Why.ComboBox2.Clear
Dim k As Integer
k = 2
Do Until IsEmpty(Cells(2, k))
prod = Workbooks("specs.xls").Worksheets("ProductIdentity ").Cells(2, k)
Why.ComboBox2.AddItem (prod)
k = k + 1
Loop
ActiveWorkbook.Sheets("Blank").Select
End If
End Sub

Thanks for any help
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default ComboBox Problems

Private Sub CommandButton3_Click()
If Why.ComboBox1.Text = "-KAJ" Then
Why.ComboBox2.Clear
'Filling second combobox
Dim j As Integer
j = 2
With Workbooks("specs.xls").Worksheets("ProductIdentity ")
Do Until IsEmpty(.Cells(4, j))
prod = .Cells(4, j)
Why.ComboBox2.AddItem (prod)
j = j + 1
Loop
End With
ActiveWorkbook.Sheets("Blank").Select
ElseIf Why.ComboBox1.Text = "-AA" Then
'Filling second combobox
Why.ComboBox2.Clear
Dim k As Integer
k = 2
With Workbooks("specs.xls").Worksheets("ProductIdentity ")
Do Until IsEmpty(.Cells(2, k))
prod = .Cells(2, k)
Why.ComboBox2.AddItem (prod)
k = k + 1
Loop
End With
ActiveWorkbook.Sheets("Blank").Select
End If
End Sub

The macro is triggered by a change in the value of Combobox3.

--
Regards,
Tom Ogilvy

"trini" wrote in message
...
Hi everyone,
I made a userform that has some option buttons and two comboboxes. The

user
choses from the two groups of option buttons and then goes to the first
combobox. I want the information in the second combobox to change

depending
on what the person choses from the first combobox. I am having some

problems.
It works well the first time but if the user changes their mind (i.e.

choses
something else in the first combobox) the second combobox does not

respond.
It clears and no new information is put in
Here is my code

COMMANDBUTTON3 ACTIVATES THE CHANGING OF COMBOBOX2, DEPENDING ON

COMBOBOX1
INFORMATION

Private Sub CommandButton3_Click()
If Why.ComboBox1.Text = "-KAJ" Then
Why.ComboBox2.Clear
'Filling second combobox
Dim j As Integer
j = 2
Do Until IsEmpty(Cells(4, j))
prod = Workbooks("specs.xls").Worksheets("ProductIdentity ").Cells(4,

j)
Why.ComboBox2.AddItem (prod)
j = j + 1
Loop
ActiveWorkbook.Sheets("Blank").Select
End If
If Why.ComboBox1.Text = "-AA" Then
'Filling second combobox
Why.ComboBox2.Clear
Dim k As Integer
k = 2
Do Until IsEmpty(Cells(2, k))
prod = Workbooks("specs.xls").Worksheets("ProductIdentity ").Cells(2,

k)
Why.ComboBox2.AddItem (prod)
k = k + 1
Loop
ActiveWorkbook.Sheets("Blank").Select
End If
End Sub

Thanks for any help



Reply
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
Problems with Combobox MBais[_2_] Excel Programming 3 July 25th 05 01:37 PM
ComboBox Problems Darrin Henry[_2_] Excel Programming 1 April 15th 05 10:07 PM
ComboBox problems !! Jako[_24_] Excel Programming 4 June 21st 04 04:52 AM
Combobox Visibility Problems anthonyvassallo Excel Programming 1 November 7th 03 03:30 PM
ComboBox Problems Darrin Henry Excel Programming 1 September 16th 03 01:23 AM


All times are GMT +1. The time now is 12:31 AM.

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"