Find Row Using 3 ComboBoxes As Criteria
That code should work. If it isn't you need to debug it and see why it isn't
working.
One problem could be that some of your columns where you need to match are
numbers. Values in a combobox are always strings (even if they look like
numbers). this could be your problem. In the example I set up and tested,
the second column was a number, so I converted the cb2.value like this
clng(cb2.value) = cell.offset(0,1).value
you could also do
cb2.value = cell.offset(0,2).Text
as long as you don't have special formatting applied that doesn't appear in
the combobox.
this was taken from a userform where it was working very well:
Private Sub CommandButton1_Click()
For Each c In Range("ReceiptList").Columns(1).Cells
If CB1.Value = c.Value _
And CLng(CB2.Value) = c.Offset(0, 1).Value _
And CB3.Value = c.Offset(0, 2).Value Then
TB5.Value = c.Offset(0, 3).Value
TB6.Value = c.Offset(0, 4).Value
Exit Sub
End If
Next c
End Sub
--
Regards,
Tom Ogilvy
"Minitman" wrote:
Hey Tom,
Thanks for the reply, that takes care of the mismatch error.
Now I see that this approach is not working.
What is the best way to get the value of columns D & E in the row that
matches CB1, CB2 & CB3 on columns A, B & C.
Any ideas? I am at a loss, everything that I tried has failed.
looking forward to hearing from you soon.
-Minitman
On Wed, 19 Jul 2006 09:47:02 -0700, Tom Ogilvy
wrote:
For Each c In Range("ReceiptList").columns(1).Cells
If CB1.Value = c.Value And _
CB2.Value = c.Offset(0, 1).Value _
And CB3.Value = c.Offset(0, 2) _
Value Then
TB5.Value = c.Offset(0, 3).Value
TB6.Value = c.Offset(0, 5).Value
Exit Sub
End If
Next c
|