+ Reply to Thread
Results 1 to 7 of 7

Type mismatch error

  1. #1
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Type mismatch error

    I have the following code:


    Please Login or Register  to view this content.



    when the contents of colulmn1 on sheet1 has exactly 7 entries then i get a type mismatch error. When there are more than 7 everything works out fine.

    I want to put into the array all the elements in col1 of sheet1 that are from row 7 on down.

    any ideas? i am enclosing a file as well.
    Attached Files Attached Files
    Last edited by welchs101; 07-15-2011 at 09:37 AM.

  2. #2
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: Type mismatch error

    removed a couple of "end ifs" so it would run as i stated in the previous post.

    Still get the type mismatch error
    Attached Files Attached Files

  3. #3
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: Type mismatch error

    basically, if there is just one element in the array I get the error.......any ideas why?

  4. #4
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Type mismatch error

    Because it's not an array - it's just a value. You could do something like:
    Please Login or Register  to view this content.
    also, two words: OPTION EXPLICIT.
    Remember what the dormouse said
    Feed your head

  5. #5
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: Type mismatch error

    THANKS!!!!!!!!!!

    In looking at your code.......i think it was the REDIM statement that i fixed the problem. but also i like your code.

    Another question on this. How come i had to use the REDIM statement. In previous uses of this type of assignment i never had to use the REDIM statemenet

    For example:
    This would need the redim statement

    Please Login or Register  to view this content.


    while this one would not


    Please Login or Register  to view this content.

  6. #6
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Type mismatch error

    If it's one cell, you get a variable of whatever datatype is in that cell, not an array. If it's more than one, you get an array because nothing else makes sense.

  7. #7
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: Type mismatch error

    thanks. that clears it up for me. i did not know this...thanks.

+ 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