Refering to 2nd Column in a Combobox

C

Corey

When using a Combobox with more than 1 CoumnCounts :

If i use the "ComboBox2.Value" line i get the Value in Column 1
How do i refer to the 2nd Column ?

Combobox2(Column(2).Value ??


Corey....
 
M

merjet

MsgBox ComboBox2.List(2, 1)
will give the 3rd row, 2nd column (since the base is 0) of ComboBox2.
ComboBox2.Value would give you the value in the BoundColumn of the
selected row.

Hth,
Merjet
 
C

Corey

So how do i get the Value in the 2nd column not the boundcolumn?
The MsgBox ComboBox2.List(2, 1) sems to give me a irrellevant value??
MsgBox ComboBox2.List(2, 1)
will give the 3rd row, 2nd column (since the base is 0) of ComboBox2.
ComboBox2.Value would give you the value in the BoundColumn of the
selected row.

Hth,
Merjet
 
M

merjet

Corey,

I checked what I wrote in #2 and it was accurate.

I can't see what you do to get your results. If you want to send an
Excel file to my e-mail address, maybe with some guidance on how to
replicate what you are doing, I will take a look.

Merjet
 
C

Corey

So if i have 2 columns in Combobox2 and the Values Chosen(Displayed) was:

ALPHABET SOUP


On a msg & Combobox2.value would display ALPHABET


If i wanted to display BOTH values i would do what:

Msg & Combobox2.value & Combobox2.(List2,1)

To show :

ALPHABET SOUP in the MSG???




Corey,

I checked what I wrote in #2 and it was accurate.

I can't see what you do to get your results. If you want to send an
Excel file to my e-mail address, maybe with some guidance on how to
replicate what you are doing, I will take a look.

Merjet
 
M

merjet

Either of these should work:
1. MsgBox ComboBox2.Value & " " & ComboBox2.List(ListIndex, 1)
if BoundColumn = 1 and ALPHABET in selected row
2. MsgBox ComboBox2.List(2,0) & " " & ComboBox2.List(2, 1)
if ALPHABET in the 3rd row (2nd since counting starts with 0)

Merjet
 
C

Corey

I have the BoundColumn =2
ColumnCount=2
And ALPHABET is on the LEFT SIde of the Combobox.

I still seem to get illogical numerical values in the other value in the msg.

Where:
ALPHABET SOUP


I get

ALPHABET 13


??


Using :


MsgBox & ComboBox2.Value & " " & ComboBox2.List(2, 0)


Either of these should work:
1. MsgBox ComboBox2.Value & " " & ComboBox2.List(ListIndex, 1)
if BoundColumn = 1 and ALPHABET in selected row
2. MsgBox ComboBox2.List(2,0) & " " & ComboBox2.List(2, 1)
if ALPHABET in the 3rd row (2nd since counting starts with 0)

Merjet
 
T

Tom Ogilvy

sVal1 = "": sVal2=""
With Combobox2
if .ListIndex <> -1 then
sVal2 = .List(.ListIndex,1)
sVal1 = .List(.Listindex,0)
end if
End With

msgbox sVal1 & " " & sVal2
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top