Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default use selected value from one combobox to populate another combobox


I need to set up 2 ComboBoxes. ComboBox1 contains two choices; "backen
tools" or "frontend tools". Depending on the selected choice ComboBox
will bring up a list of tools relating to that choice. So what I nee
to know is how to pass the selected ComboBox1.Text value to ComboBox2
Once I have the value I can put an 'if' statement in the ComboBox2 cod
such as:

if passed value = "backend" then
ComboBox2.AddItem("tool1")
ComboBox2.AddItem("tool2")
end if

if passed value = "frontend" then
ComboBox2.AddItem("tool10")
ComboBox2.AddItem("tool11")
end if
Cheers

Robbie:confused

--
rjudg
-----------------------------------------------------------------------
rjudge's Profile: http://www.excelforum.com/member.php...fo&userid=3298
View this thread: http://www.excelforum.com/showthread.php?threadid=53286

  #2   Report Post  
Posted to microsoft.public.excel.programming
GS GS is offline
external usenet poster
 
Posts: 364
Default use selected value from one combobox to populate another combobox

Assuming your code is behind the userform that contains both ComboBox
controls, you could try this in the Change event for ComboBox1

If Me.Value = "backend" Then
With ComboBox2
.AddItem "tool1"
.AddItem "tool2"
End With
Else
With ComboBox2
.AddItem "tool10"
.AddItem "tool11"
End With
End If

HTH
Regards,
Garry
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default use selected value from one combobox to populate another combo

Think Gary left out part of his code: (ME refers to the Userform containing
the code or if on a worksheet, the worksheet containing the code module).

If Me.Combobox1.Value = "backend" Then
With Me.ComboBox2
.AddItem "tool1"
.AddItem "tool2"
End With
Else
With Me.ComboBox2
.AddItem "tool10"
.AddItem "tool11"
End With
End If


--
Regards,
Tom Ogilvy


"GS" wrote:

Assuming your code is behind the userform that contains both ComboBox
controls, you could try this in the Change event for ComboBox1

If Me.Value = "backend" Then
With ComboBox2
.AddItem "tool1"
.AddItem "tool2"
End With
Else
With ComboBox2
.AddItem "tool10"
.AddItem "tool11"
End With
End If

HTH
Regards,
Garry

  #4   Report Post  
Posted to microsoft.public.excel.programming
GS GS is offline
external usenet poster
 
Posts: 364
Default use selected value from one combobox to populate another combo

Thanks Tom, ...you're absolutely correct.

To the OP:
My apologies for the careless omission!

Also, you may want to include clearing the ComboBox2 list before adding any
items in case the user changes selections in ComboBox1. Otherwise, the new
items will be added to any existing items in the list. Also, I added a line
to clear the .Value so nothing is selected.

Revised (with Tom's correction) to include:

If Me.Combobox1.Value = "backend" Then
With Me.ComboBox2
.Clear
.AddItem "tool1"
.AddItem "tool2"
End With
Else
With Me.ComboBox2
.Clear
.AddItem "tool10"
.AddItem "tool11"
End With
End If
Me.ComboBox2.Value = "" 'make sure nothing is selected

Regards,
Garry
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
How do i populate a text box according to selection in combobox? Steve Excel Worksheet Functions 0 April 13th 06 12:40 PM
Populate a Combobox from range. ex1302[_8_] Excel Programming 14 July 22nd 05 05:32 PM
Populate combobox Pat Excel Programming 1 December 10th 04 05:33 PM
populate combobox with sheet names David Goodall Excel Programming 3 September 12th 04 12:37 PM
Populate a combobox Rory[_3_] Excel Programming 2 June 9th 04 04:20 PM


All times are GMT +1. The time now is 06:25 PM.

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

About Us

"It's about Microsoft Excel"