+ Reply to Thread
Results 1 to 4 of 4

Using Range.clearcontents causing type mismatch error in code

  1. #1
    Registered User
    Join Date
    05-28-2014
    Posts
    3

    Using Range.clearcontents causing type mismatch error in code

    Hi all,

    I have a routine that uses two subs in vba to run through some iterations in excel. the code is working great but when I added a line to clear a range where a table is built each time we run the routine, I get Error: type mismatch.

    FYI: the second sub "System_Analysis" is what is initially ran and inside of it, the sub "Golf" is invoked. Sorry if the order is confusing.

    Please Login or Register  to view this content.
    When I step through the code, the error happens after I call 'Golf' and return to system analysis to execute the next line. after reading online I think it is because the range is multiple cells and my next line sets a value for a single cell. Please help this is driving me crazy. again the code works like a charm without the .clearcontents line which is really confusing me.

    Thanks and I really appreciate any help,
    Capt

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

    Re: Using Range.clearcontents causing type mismatch error in code

    Does the error actually occur on the ClearContents line?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    05-28-2014
    Posts
    3

    Re: Using Range.clearcontents causing type mismatch error in code

    Thanks for the quick response.

    no it clears the range just fine and finishes the sub Golf no problem. its when the code returns to System_Analysis on the very next line after Call Golf that the error occurs on.

  4. #4
    Registered User
    Join Date
    05-28-2014
    Posts
    3

    Re: Using Range.clearcontents causing type mismatch error in code

    Norie, really thank you for looking at this. I have found the problem and fixed it. I was clearing the table everytime golf was called instead of clearing the table once at the beginning of System_Analysis. that put blanks on fields that were used in calculations so it was throwing the error. I am sorry to have wasted your time though your reply did make me see what I was doing wrong so thank you!!

+ 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. [SOLVED] Error 13, type mismatch from code.
    By Nitefox in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-25-2014, 05:14 AM
  2. [SOLVED] #Value in array causing Type Mismatch in comparision
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-04-2013, 01:40 PM
  3. [SOLVED] Type Mismatch error ==> do some code before exiting sub
    By drawing.blanks in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-27-2012, 10:42 PM
  4. type mismatch error in code
    By strikeofdawn in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-08-2008, 08:34 PM
  5. Type Mismatch error in VBA code
    By bobby in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-10-2005, 04:10 AM

Tags for this Thread

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