ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   ComboBox (https://www.excelbanter.com/excel-programming/340036-combobox.html)

Syed Haider Ali[_19_]

ComboBox
 

Hi Dears,

I want to build two Combo Boxes i.e ComboBox1 having range "a1: a50"
and ComboBox2 having range "c1:c25". on a same userForm.

for a simple single comboBox we use these codes

Private sub userForm_activate()

Sheet1.activate
ComboBox1.columncount=1
Combobox1.rowsource="a1:a50"

end sub

but i need code to show Combobox2 on the same userForm have range
"c1:c25" as well as combobox1 having range "a1:a50".



Thanks

Syed Haider Ali


--
Syed Haider Ali
------------------------------------------------------------------------
Syed Haider Ali's Profile: http://www.excelforum.com/member.php...o&userid=21994
View this thread: http://www.excelforum.com/showthread...hreadid=467474


Bob Phillips[_6_]

ComboBox
 
This seems too obvious, so I may b e missing something

Private sub userForm_activate()

Sheet1.activate
ComboBox1.columncount=1
Combobox1.rowsource="a1:a50"
ComboBox2.columncount = 1
Combobox2.rowsource = "C1:C25"


end sub


--
HTH

Bob Phillips

"Syed Haider Ali"
<Syed.Haider.Ali.1vco2c_1126703136.4879@excelfor um-nospam.com wrote in
message news:Syed.Haider.Ali.1vco2c_1126703136.4879@excelf orum-nospam.com...

Hi Dears,

I want to build two Combo Boxes i.e ComboBox1 having range "a1: a50"
and ComboBox2 having range "c1:c25". on a same userForm.

for a simple single comboBox we use these codes

Private sub userForm_activate()

Sheet1.activate
ComboBox1.columncount=1
Combobox1.rowsource="a1:a50"

end sub

but i need code to show Combobox2 on the same userForm have range
"c1:c25" as well as combobox1 having range "a1:a50".



Thanks

Syed Haider Ali


--
Syed Haider Ali
------------------------------------------------------------------------
Syed Haider Ali's Profile:

http://www.excelforum.com/member.php...o&userid=21994
View this thread: http://www.excelforum.com/showthread...hreadid=467474




Syed Haider Ali[_20_]

ComboBox
 

Thanks Bob. I got it.

One thing more can we set a default value at combobox whenever we run
a userForm.

Thanks

Syed Haider Ali


--
Syed Haider Ali
------------------------------------------------------------------------
Syed Haider Ali's Profile: http://www.excelforum.com/member.php...o&userid=21994
View this thread: http://www.excelforum.com/showthread...hreadid=467474


Bob Phillips[_6_]

ComboBox
 
You can set an item to show as selected if that is what you mean by setting
the value of ListIndex.

--
HTH

Bob Phillips

"Syed Haider Ali"
<Syed.Haider.Ali.1vcz6t_1126717532.0969@excelfor um-nospam.com wrote in
message news:Syed.Haider.Ali.1vcz6t_1126717532.0969@excelf orum-nospam.com...

Thanks Bob. I got it.

One thing more can we set a default value at combobox whenever we run
a userForm.

Thanks

Syed Haider Ali


--
Syed Haider Ali
------------------------------------------------------------------------
Syed Haider Ali's Profile:

http://www.excelforum.com/member.php...o&userid=21994
View this thread: http://www.excelforum.com/showthread...hreadid=467474




Syed Haider Ali[_21_]

ComboBox
 

Can you explain more in detail with the help of codes

Thanks

Syed Haider Ali


--
Syed Haider Ali
------------------------------------------------------------------------
Syed Haider Ali's Profile: http://www.excelforum.com/member.php...o&userid=21994
View this thread: http://www.excelforum.com/showthread...hreadid=467474


Bob Phillips[_6_]

ComboBox
 
Combobox1.ListIndex = 2

will select the third item.

--
HTH

Bob Phillips

"Syed Haider Ali"
<Syed.Haider.Ali.1ved6i_1126782329.4465@excelfor um-nospam.com wrote in
message news:Syed.Haider.Ali.1ved6i_1126782329.4465@excelf orum-nospam.com...

Can you explain more in detail with the help of codes

Thanks

Syed Haider Ali


--
Syed Haider Ali
------------------------------------------------------------------------
Syed Haider Ali's Profile:

http://www.excelforum.com/member.php...o&userid=21994
View this thread: http://www.excelforum.com/showthread...hreadid=467474




Syed Haider Ali[_22_]

ComboBox
 

Thanks Bob for your reply.

One thing more can we do that when we select the value throug
comboBox1. The same value show in comboBox1 when we re-Open UserFor
next time. And if we Select other value through ComboBox1 then agai
next when we open the userForm the Last time selected value shows i
ComboBox1.


Thanks

Syed Haider Al

--
Syed Haider Al
-----------------------------------------------------------------------
Syed Haider Ali's Profile: http://www.excelforum.com/member.php...fo&userid=2199
View this thread: http://www.excelforum.com/showthread.php?threadid=46747


Bob Phillips[_6_]

ComboBox
 
You would need to save the value selected, or the ListIndex, when you close
the form down, and then check that value when you load it next time. In a
single Excel session, you can hide and show the form, and that preserves it,
but in multiple sessions, you need to manage it.

--
HTH

Bob Phillips

"Syed Haider Ali"
<Syed.Haider.Ali.1ver2g_1126800392.2445@excelfor um-nospam.com wrote in
message news:Syed.Haider.Ali.1ver2g_1126800392.2445@excelf orum-nospam.com...

Thanks Bob for your reply.

One thing more can we do that when we select the value through
comboBox1. The same value show in comboBox1 when we re-Open UserForm
next time. And if we Select other value through ComboBox1 then again
next when we open the userForm the Last time selected value shows in
ComboBox1.


Thanks

Syed Haider Ali


--
Syed Haider Ali
------------------------------------------------------------------------
Syed Haider Ali's Profile:

http://www.excelforum.com/member.php...o&userid=21994
View this thread: http://www.excelforum.com/showthread...hreadid=467474





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

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