+ Reply to Thread
Results 1 to 6 of 6

Runtime Error 13 Type Mismatch

  1. #1
    Registered User
    Join Date
    03-14-2012
    Location
    Richmond, VA
    MS-Off Ver
    Excel 2007
    Posts
    10

    Runtime Error 13 Type Mismatch

    Dear Forum,

    I'm having a bit of an issue with a script I'm writing, and I'm hoping that someone here can help. My issue is i'm getting a runtime error 13 Type Mismatch when I try to run my code. I think the issue lies in the fact that i want my script to be ran on every cell in the column because if i run my script on just one cell say "s2" it works just fine. However, when I expand the cell range reference to capture the entire oolumn I get the error. I read somewhere blank cells in the columns where my script is interacting with the data validation lists could create a problem, and it also could be that the compiler expects one data type, but is seeing another data type. Here's my code, hopefully someone can help me make sense of what i'm doing wrong. I've been working on this project for a week now, and this is the last hurdle to clear before it's completed. Any help you guys can give is greatly appreciated.

    Please Login or Register  to view this content.
    Last edited by Vaibhav; 03-19-2012 at 08:19 AM.

  2. #2
    Registered User
    Join Date
    03-14-2012
    Location
    Richmond, VA
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Runtime Error 13 Type Mismatch

    http://www.ozgrid.com/forum/showthread.php?t=163511, Cross Posted Here:

  3. #3
    Forum Contributor
    Join Date
    12-28-2011
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    280

    Re: Runtime Error 13 Type Mismatch

    Hi

    It is because a multicell range returns an array when you access its Value property and you therefore get the type mismatch when your If tries to compare this array to a single string value (such as "PLX").

    Would you mind explaining in words what you want your code to do? Something along the lines of "If a V col value is changed then if the V cell = 'PLX' then modify some other cell by..."

  4. #4
    Registered User
    Join Date
    03-14-2012
    Location
    Richmond, VA
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Runtime Error 13 Type Mismatch

    [QUOTE=Firefly2012;2737151]Hi

    It is because a multicell range returns an array when you access its Value property and you therefore get the type mismatch when your If tries to compare this array to a single string value (such as "PLX").

    Would you mind explaining in words what you want your code to do? Something along the lines of "If a V col value is changed then if the V cell = 'PLX' then modify some other cell by..."[/QUOTE

    To explain my situation a little better. I have three dependent data validation lists set up in columns Q, R, and S. What I want the code to do is take the choices made in the three data validation lists and compare them to an exact criteria and return a value based on a match to specific criteria. For example if the user chooses "PLX" in column Q and "Imaging_TopCall" in column R and finally "Missing From File" in column S then column U auto populates with "Level 1". A record will be evaluated on every row of the spreadsheet, thus the necessity to have my code run over the entire range of all four columns involved with my code. Is there a way to rewrite my code so that it functions correctly? Any example you can give would be a great help. Thanks so much man>

  5. #5
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Runtime Error 13 Type Mismatch

    vtsoldier2010,

    Give this a try. The code assumes that multiple cells in Range("Q2:S" & Rows.Count) can change simultaneously. If it's guaranteed that only 1 cell at a time will change, the code can be greatly simplified:
    Please Login or Register  to view this content.
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  6. #6
    Registered User
    Join Date
    03-14-2012
    Location
    Richmond, VA
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Runtime Error 13 Type Mismatch

    Bump: No Response

+ 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