Application.Vlookup Type Mismatch Error

  • Thread starter Thread starter ssjody
  • Start date Start date
S

ssjody

I know this is going to be something really easy but I am having troubl
figuring it out. I keep getting a Type MisMatch Error on this:
bmrp = Application.VLookup(ComboBoxJumpToPart.Value, bmlu, 4, False)
I tried setting Dim bmrp As Variant but bmlu returns an integer an
bmrp returns a string which causes my code to fail.
Any Ideas? I'm stuck. Thanks Jody

Dim bmrp As String
Set bmlu = Range("BidmateParts")
bmrp = Application.VLookup(ComboBoxJumpToPart.Value, bmlu, 4, False)

If IsError(bmrp) Then
MsgBox "Yep, it's an error!"

Else
If Me.TextBoxGradeA_RetailValue.Value < (bmrp) Then
Me.TextBoxGradeA_RetailValue.Value = (bmrp)
Me.TextBoxGradeA_RetailValue.ForeColor = &HFF&
Me.LabelBidmatePriceDiffers.Visible = True
Me.LabelRetailPriceRaiseLower.Visible = True
Me.LabelRetailPriceRaiseLower.Caption = "Raised"
ElseIf Me.TextBoxGradeA_RetailValue.Value > (bmrp) Then
Me.TextBoxGradeA_RetailValue.Value = (bmrp)
Me.TextBoxGradeA_RetailValue.ForeColor = &HFF&
Me.LabelBidmatePriceDiffers.Visible = True
Me.LabelRetailPriceRaiseLower.Visible = True
Me.LabelRetailPriceRaiseLower.Caption = "Lowered"
ElseIf Me.TextBoxGradeA_RetailValue.Value = (bmrp) Then
Me.LabelBidmatePriceDiffers.Visible = False
Me.TextBoxGradeA_RetailValue.ForeColor = &H80000008
Me.LabelRetailPriceRaiseLower.Visible = False
End If
End I
 
if the vlookup always returns a number and you want it to be a strin
try

bmrp=cstr(vlookup ....)

if it can return either a string or a number then use a variant

dim v as variant
v=vlookup(....)
bmrp=v

hope this help
 

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

Back
Top