Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 252
Default How to assign value back to a dropdown combo

Hi all,

My dropdown combo has two columns, one is for text and one is for value.
When coding, is it possible to assign a text to it while the corresponding
value is also assigned to it?

Clara
--
thank you so much for your help
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default How to assign value back to a dropdown combo

Use the object.AddItem and object.List properties [object.list(row, column)]

With ComboBox1 'Rename ComboBox1 to the name of your control
.Additem "Your Text here"
.List(0, 1) = "1" 'Or any other value you assign
.Additem "Text line two"
.List(1, 1) = "2"
.Additem "Text line three"
.List(2, 1) = "3"
End With

'If you don't use the 'With' statement then it would be more typing.
'Like so:

ComboBox1.Additem "Your Text here"
ComboBox1.List(0, 1) = "1" 'Or any other value you assign
ComboBox1.Additem "Text line two"
ComboBox1.List(1, 1) = "2"
ComboBox1.Additem "Text line three"
ComboBox1.List(2, 1) = "3"

'For more information, look in the Help guide for AddItem and List
'Hope this helps


"clara" wrote:

Hi all,

My dropdown combo has two columns, one is for text and one is for value.
When coding, is it possible to assign a text to it while the corresponding
value is also assigned to it?

Clara
--
thank you so much for your help

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 252
Default How to assign value back to a dropdown combo

Hi IT_roofer,

Thank you for your answer. you misunderstood my question. My question is
like the following:

if a combo box has two columns, one is for text(display) and the other one
is for value, when we click it , it will display a list of text , when we
refer to it, it will give use the value behide. if we do not click it first,
instead we assign it one of its text list, is it possible to get the
corresponding value?

Clara



--
thank you so much for your help


"IT_roofer" wrote:

Use the object.AddItem and object.List properties [object.list(row, column)]

With ComboBox1 'Rename ComboBox1 to the name of your control
.Additem "Your Text here"
.List(0, 1) = "1" 'Or any other value you assign
.Additem "Text line two"
.List(1, 1) = "2"
.Additem "Text line three"
.List(2, 1) = "3"
End With

'If you don't use the 'With' statement then it would be more typing.
'Like so:

ComboBox1.Additem "Your Text here"
ComboBox1.List(0, 1) = "1" 'Or any other value you assign
ComboBox1.Additem "Text line two"
ComboBox1.List(1, 1) = "2"
ComboBox1.Additem "Text line three"
ComboBox1.List(2, 1) = "3"

'For more information, look in the Help guide for AddItem and List
'Hope this helps


"clara" wrote:

Hi all,

My dropdown combo has two columns, one is for text and one is for value.
When coding, is it possible to assign a text to it while the corresponding
value is also assigned to it?

Clara
--
thank you so much for your help

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default How to assign value back to a dropdown combo

Oops, sorry about that. Are you looking for the index number of the text in
the list or are you looking for a numerical value in column 2 that
correspinds to the text in column 1?



"clara" wrote:

Hi IT_roofer,

Thank you for your answer. you misunderstood my question. My question is
like the following:

if a combo box has two columns, one is for text(display) and the other one
is for value, when we click it , it will display a list of text , when we
refer to it, it will give use the value behide. if we do not click it first,
instead we assign it one of its text list, is it possible to get the
corresponding value?

Clara



--
thank you so much for your help


"IT_roofer" wrote:

Use the object.AddItem and object.List properties [object.list(row, column)]

With ComboBox1 'Rename ComboBox1 to the name of your control
.Additem "Your Text here"
.List(0, 1) = "1" 'Or any other value you assign
.Additem "Text line two"
.List(1, 1) = "2"
.Additem "Text line three"
.List(2, 1) = "3"
End With

'If you don't use the 'With' statement then it would be more typing.
'Like so:

ComboBox1.Additem "Your Text here"
ComboBox1.List(0, 1) = "1" 'Or any other value you assign
ComboBox1.Additem "Text line two"
ComboBox1.List(1, 1) = "2"
ComboBox1.Additem "Text line three"
ComboBox1.List(2, 1) = "3"

'For more information, look in the Help guide for AddItem and List
'Hope this helps


"clara" wrote:

Hi all,

My dropdown combo has two columns, one is for text and one is for value.
When coding, is it possible to assign a text to it while the corresponding
value is also assigned to it?

Clara
--
thank you so much for your 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
Combo Box / Dropdown Box HELP!!!! Katmouse Excel Discussion (Misc queries) 3 January 6th 09 06:36 PM
assign a macro to a combo box dave caizley Excel Discussion (Misc queries) 2 September 20th 07 08:58 AM
assign a macro to a combo box dave caizley Excel Discussion (Misc queries) 0 September 19th 07 11:08 AM
Combo Box Dropdown Menu Alok Excel Programming 0 January 6th 07 04:49 PM
Assign Macros to a dropdown list JT Excel Programming 6 November 12th 04 12:43 AM


All times are GMT +1. The time now is 10:18 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"