+ Reply to Thread
Results 1 to 3 of 3

Application.Vlookup Type Mismatch Error

  1. #1
    Registered User
    Join Date
    04-12-2006
    Posts
    39

    Application.Vlookup Type Mismatch Error

    I know this is going to be something really easy but I am having trouble 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 and 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 If

  2. #2
    Valued Forum Contributor tony h's Avatar
    Join Date
    03-14-2005
    Location
    England: London and Lincolnshire
    Posts
    1,186
    if the vlookup always returns a number and you want it to be a string 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 helps

  3. #3
    Registered User
    Join Date
    04-12-2006
    Posts
    39
    Thanks Tony! The cStr was what I needed. That fixed my problem.

    Jody

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1