Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

combo box row value 1

Status
Not open for further replies.

cc4mail

Technical User
Jan 8, 2002
47
US
What is the simple way to capture the combo box row value?

I have a combo box with employee information (combobox_emp).

I want to capture the row selected by the user to a variable (varEmp)

this is used to later populate dynamic text boxes.
textbox.text= Sheet2.Cells(varRow, 1) ... etc

Thanks - it's simple, but I'm not an excel guy.
 
cc4mail,

The selected value in a combobox
Code:
MyValue = Sheet1.Combobox1.Value
To assign values to a combobox use the AddItem method
Code:
Sheet1.Combobox1.AddItem MyOtherValue
:)

Skip,

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Sorry, didn't make this real clear.

I want the numerical index (array) value of the row, not value of the content of the row. something like {combobox1.row()}

thanks...
 
additionally, this is for a user in Excel 97.

Boy, I need to stick with HTML

Thanks
 
Skip,

It makes perfect sense, should work, but does not. What am I missing?

Private Sub ComboBox_Ofcr_Change()

varRow = Sheet1.ComboBox_Ofcr.Index

TextBox_Ofcr.Text = Sheet2.Cells(varRow, 1) + ", " +
Sheet2.Cells(varRow, 2) + " " + Sheet2.Cells(varRow, 3) + " -- Ser #" + Sheet2.Cells(varRow, 4) + " " + Sheet2.Cells(varRow, 5) + " " + Sheet2.Cells(varRow, 6)

TextBox_Notes.Text = ""

End Sub
 
So what's NOT happening? What value of varRow is NOT working?
Code:
Private Sub ComboBox_Ofcr_Change()

varRow = Sheet1.ComboBox_Ofcr.Index

With Sheet2
    TextBox_Ofcr.Text = .Cells(varRow, 1) + ", " + _
                        .Cells(varRow, 2) + " " + _
                        .Cells(varRow, 3) + " -- Ser #" + _
                        .Cells(varRow, 4) + "   " + _
                        .Cells(varRow, 5) + " " + _
                        .Cells(varRow, 6)
End With

TextBox_Notes.Text = ""

End Sub


Skip,

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Skip

Regardless of the row selected in the Combo Box, the index value returns as 3. (There are 300+ rows in the ComboBox and sheet 2).

 
Skip,

Thanks, it seemed simple, but I was banging my head against the wall.

Thanks for staying at it so long. It worked!!!

Many stars!

Craig [thumbsup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top