ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Dependant combo boxes (https://www.excelbanter.com/excel-programming/360981-dependant-combo-boxes.html)

harpscardiff[_23_]

Dependant combo boxes
 

Hi,

I've got a form with frames, text boxes, multipages and drop downs.
On one of the mulitpages, (page 1), I have two combo boxes, combo1 and
combo2.

Combo1 has main catergories:
Hardware
Software

I want combo2 to have results based on which option is selected from
combo1.

Combo2 if hardwa
PC
Monitor
Keyboard
Mouse
Telephone
Printer

Combo2 if softwa
Word
Excel
power point
outlook

[ F O N T = \ " A r i a l B l a c k \ " ] A n y c h a n c e t h
i s c a n b e d o n e ? [ / F O N T ]

I've tried for hardwa


Code:
--------------------
Private Sub txtsubcat_AfterUpdate()
If combo1.Value = "PC" Then
With txtsubcat
.AddItem ("PC Base Unit")
.AddItem ("Monitor")
.AddItem ("Keyboard")
.AddItem ("Mouse")
End With

End If
End Sub

--------------------


--
harpscardiff
------------------------------------------------------------------------
harpscardiff's Profile: http://www.excelforum.com/member.php...o&userid=25960
View this thread: http://www.excelforum.com/showthread...hreadid=540346


Toppers

Dependant combo boxes
 
Create named ranges named "Hardware" and "Software" and then modify sample
code below:

Private Sub ComboBox1_Change()
ComboBox2.RowSource = ComboBox1.Value
End Sub

Private Sub UserForm_Initialize()
With ComboBox1
.AddItem "Hardware"
.AddItem "Software"
End With
End Sub


HTH

"harpscardiff" wrote:


Hi,

I've got a form with frames, text boxes, multipages and drop downs.
On one of the mulitpages, (page 1), I have two combo boxes, combo1 and
combo2.

Combo1 has main catergories:
Hardware
Software

I want combo2 to have results based on which option is selected from
combo1.

Combo2 if hardwa
PC
Monitor
Keyboard
Mouse
Telephone
Printer

Combo2 if softwa
Word
Excel
power point
outlook

[ F O N T = \ " A r i a l B l a c k \ " ] A n y c h a n c e t h
i s c a n b e d o n e ? [ / F O N T ]

I've tried for hardwa


Code:
--------------------
Private Sub txtsubcat_AfterUpdate()
If combo1.Value = "PC" Then
With txtsubcat
.AddItem ("PC Base Unit")
.AddItem ("Monitor")
.AddItem ("Keyboard")
.AddItem ("Mouse")
End With

End If
End Sub

--------------------


--
harpscardiff
------------------------------------------------------------------------
harpscardiff's Profile: http://www.excelforum.com/member.php...o&userid=25960
View this thread: http://www.excelforum.com/showthread...hreadid=540346



harpscardiff[_24_]

Dependant combo boxes
 

Worked brilliantly!!

Thanks very much,


--
harpscardiff
------------------------------------------------------------------------
harpscardiff's Profile: http://www.excelforum.com/member.php...o&userid=25960
View this thread: http://www.excelforum.com/showthread...hreadid=540346



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

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