Results 1 to 3 of 3

Thread: Error 13 - Mismatch in UserForm update Application.Match with mixed Data

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,709
    Location
    CLng will throw an error if the input, (ComboBox4) contains a non numerical character.

    Try
    n = sh.Range("A:A").Find(Me.ComboBox4).Row
    BTW, the Hashmark symbol, (#,) will insert VBA Code brackets around your code

    Hint for newbies: your code will be more self documented if you name your Form Controls similar to the Data Sheet's Headers.
    Example: Column A header = Order_number. Control ComboBox4.Name = cmboOrder_Number... You can use a UserDefinedType where colOrder_Number = 1... and the variable n is named RecordRow

    Private Type DataMaster_Columns
       colOrder_Number = 1
       colNextHeader1 'Generic
       colNextHeader2 'Generic
       colOrderDate   
       colEtc
    End Type
    Revised code example:
    RecordRow = .Columns(colOrder_Number).Find(Me.CmboOrder_Number).Row
    With sh. Rows(RecordRow)
       Me.txbxNextHeader1 = .Cells(colNextHeader1) 'Generic
       Me.txbxNextHeader2 = .Cells(colNextHeader2) 'Generic
       Me.dpkrOrder_Date = .Cells(colOrderDate)
       Me.obutEmail = .Cells(colCustomerContactType) = "eMail"
       Me.obutPhone = .Cells(colCustomerContactType) = ""Phone""
       Me.obutCustomer_Thermometer = .Cells(colCustomerContactType) = "Customer Thermometer"
       etc
    End With
    Note this means a lot of CopyPasta (no Typos) and three or four character editing. I usually start by copying the Headers, then PasteSpecial.Transpose into a column on a new sheet. From there I C&P to name all the Form Controls. Then I will place "col" into the preceding Sheet Column and use "=A&B" in the next column and fill down both. Copying that column values gives me the variables for the UserDefined Type.

    The act of copying a header name from that vertical list, then switching back to my UserForm means that I don't forget a required Control, as well as preventing typos.

    This system is mostly so I never have to think (have a brain fart) about which Range which Control uses.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  2. #2
    VBAX Newbie
    Joined
    Apr 2020
    Posts
    2
    Location
    Dear Sam,

    Thank you very much for these explanations.
    You are right it is more self-documented if I name theForm Controls similar to the Data Sheet's Headers - > Good Tip !
    I tried the :
    n = sh.Range("A:A").Find(Me.ComboBox4).Row
    And it's working like a charm. Thank you So much! I have been searching for days and now I will modify my code with the tip you gave me.
    Thank you again very much and stay safe during these crazy times .
    Cheers,

    P.

Posting Permissions

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