View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default lookup for a combo box in VBA

Assuming your combobox is on a userform, then it sounds like you have set
the boundcolumn property to zero. This returns the ListIndex property
rather than the value selected. Change it to 1 and it should return what is
displayed in the textbox. No need to use vlookup if this is the situation.

--
Regards,
Tom Ogilvy

"Jennifer" wrote in message
...
Ok, thanks to Patrick I have my combo box working. Of coarse there is a

but,
the
combo box returns a number in the database. Do I have to write a function
in the macro to
lookup the correct text? I have used vlookup in excel but never in a

macro.
Help please! Right now in column 4 and 5 there is number instead of the
vendors name and ranch name.

This is what it looks like thus far:

Private Sub cmdAdd_Click()

' copy the data to the database
ws.Cells(iRow, 1).Value = "=R[-1]C+1"
ws.Cells(iRow, 2).Value = Me.txtInvoice.Value
ws.Cells(iRow, 3).Value = Me.txtDate.Value
ws.Cells(iRow, 4).Value = Me.cboVend.Value
ws.Cells(iRow, 5).Value = Me.cboRan.Value
ws.Cells(iRow, 7).Value = Me.txtPallet.Value
ws.Cells(iRow, 8).Value = Me.txtQty.Value
ws.Cells(iRow, 10).Value = Me.txtRepakHrs.Value
ws.Cells(iRow, 11).Value = Me.txtRepakQty.Value
ws.Cells(iRow, 12).Value = "Purchase"
Me.txtInvoice.SetFocus

End Sub





--
Though daily learning, I LOVE EXCEL!
Jennifer