+ Reply to Thread
Results 1 to 5 of 5

Type mismatch error

  1. #1
    Registered User
    Join Date
    11-23-2007
    Posts
    65

    Type mismatch error

    Hi,

    I have the following code which is giving me a type mismatch error:

    Please Login or Register  to view this content.
    The error occurs in the following part of the code. The values that I'm copying into the Code(i) array are items of text which is why I declared them as the 'variant' type of data. VBA is still not happy though.

    Please Login or Register  to view this content.
    Does anyone have any ideas where this is going wrong?

    Thanks,

    Chris

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Type mismatch error

    If you want to use Column 54 use

    Please Login or Register  to view this content.
    Note also that Option Base is by default 0 so

    Code(11) is a 12 value array (0 to 11) ... it would appear you want an 11 value array, so either:

    Please Login or Register  to view this content.
    or

    Please Login or Register  to view this content.
    (or set Option Base to 1 at top of Module)

    The alternative approach would be to use the below to populate the Array thereby avoiding need to Loop:

    Please Login or Register  to view this content.
    Last edited by DonkeyOte; 05-22-2009 at 04:48 AM.

  3. #3
    Registered User
    Join Date
    11-23-2007
    Posts
    65

    Re: Type mismatch error

    Thanks for that, but still no joy unfortunately.

    I have set the option base as 1 at the very start of editor (I have several other macros). I think therefore that Code(11) is right. I did try your other suggestion about using the alternative instead of looping to fill the array. This worked but my code fell over later on at the line:

    Please Login or Register  to view this content.
    Where it told me 'subscript out of range'?

    Do you possibly have any other suggestions?

    Thanks very much again!

    Chris

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Type mismatch error

    I will take a look in a while - up to my eyes in my own code presently ... if in the meantime anyone else can spare the time to check this out in more depth I'd be grateful.

  5. #5
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Type mismatch error

    You need to tell us what the values in the variables are
    So immediately before that line add

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

+ 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