+ Reply to Thread
Results 1 to 7 of 7

Type Mismatch Error

  1. #1
    Forum Contributor
    Join Date
    08-06-2012
    Location
    United States
    MS-Off Ver
    Excel 2013
    Posts
    119

    Angry Type Mismatch Error

    Please help me, I have been working on trying to get this sub to change the criteria in my query for about 2 days now and I just cannot figure it out. I think the problem is in the fact that Visual Basic is splitting the code into a bunch of lines, but honestly, I have no idea. I have never had this problem before. Here is my code:

    Please Login or Register  to view this content.

  2. #2
    Valued Forum Contributor fredlo2010's Avatar
    Join Date
    07-04-2012
    Location
    Miami, United States
    MS-Off Ver
    Excel 365
    Posts
    762

    Re: Type Mismatch Error

    Hello,

    See if this helps

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    08-06-2012
    Location
    United States
    MS-Off Ver
    Excel 2013
    Posts
    119

    Re: Type Mismatch Error

    Thanks for the reply! Unfortunately that did not solve the problem. I had to change your code a little because my sheets are not called 'Sheet1' 'Sheet2' ... etc. Is there anything else you changed in the code other than using Sheets("Sheet Name"). instead of Sheet1.?

    Please Login or Register  to view this content.

    I can't upload the workbook because it is massive, but I took some screen shots of what I am getting.

    Debug.JPG
    Sheet Names.JPG
    Type Mismatch.JPG

    Here is a table giving an idea of what the sheet that the macro is pulling its values from looks like and the formulas in those cells.

    Formulas
    Column D =IF(ISBLANK(INDIRECT("A"&ROW())),"",IF(ISBLANK(INDIRECT("A"&ROW()+1)),"'"&
    INDIRECT("A"&ROW())&"'","'"&INDIRECT("A"&ROW())&"'"&IF(OR(ROW()=41,ROW()=81,ROW()=121,ROW()=161,
    ROW()=201),"",",")))

    Column H =IF(csvRange(D2:D41)="","'0'",csvRange(D2:D41))

    A B C D E F G H I
    1 SKU Name Formatted SKU Include Since 2005
    2 54321 'Book Name1' '54321',
    3 98765 'Book Name2' '98765', Line Criteria
    4 76543 'Book Name3' '76543', Line 1 '54321','98765','76543',...

    Also, here is the code for the csvRange

    Please Login or Register  to view this content.
    Last edited by chaddug; 09-12-2013 at 11:26 AM.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Type Mismatch Error

    Have you checke the values in line1, line2... etc?

    Also, have you checked the query with hard-coded values?
    If posting code please use code tags, see here.

  5. #5
    Forum Contributor
    Join Date
    08-06-2012
    Location
    United States
    MS-Off Ver
    Excel 2013
    Posts
    119

    Re: Type Mismatch Error

    Quote Originally Posted by Norie View Post
    Have you checke the values in line1, line2... etc?

    Also, have you checked the query with hard-coded values?
    Im not exactly sure I understand your question, but when looking at the sheet with the line1, line2, etc values it displays then as a string of skus (so I think that is correct). And the query is working fine, I just want the people who are using this sheet to be able to just click refresh and have the macro update the query with new criteria.

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Type Mismatch Error

    I mean have you checked the values of the variables line1, line2... etc when the code runs?

    You can do that in the Locals Window (View>Locals Window).

  7. #7
    Forum Contributor
    Join Date
    08-06-2012
    Location
    United States
    MS-Off Ver
    Excel 2013
    Posts
    119

    Re: Type Mismatch Error

    This is what I get

    Attachment 264882

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Run Type error 13 Type Mismatch
    By Affan Khan in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 11-13-2012, 12:58 PM
  2. [SOLVED] Run-type error 13 type mismatch
    By misop in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-05-2012, 04:08 AM
  3. Complile Error: Type Mismatch ??? After adding error trap
    By clemsoncooz in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-22-2012, 03:50 PM
  4. Conditional Formatting - Run Time Error '13' Type Mismatch Error
    By ksp in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-17-2011, 07:37 PM
  5. [SOLVED] Help: Compile error: type mismatch: array or user defined type expected
    By lvcha.gouqizi in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-31-2005, 05:05 PM

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