+ Reply to Thread
Results 1 to 4 of 4

COUNTIF function giving Type Mismatch error

  1. #1
    Registered User
    Join Date
    10-31-2012
    Location
    Richmond, VA
    MS-Off Ver
    Excel 2010
    Posts
    12

    COUNTIF function giving Type Mismatch error

    Hi, I'm sure this is a simple problem of syntax but I'm trying to learn how to use this function so I can apply it in a larger context within a worksheet. I have the following code:

    Please Login or Register  to view this content.
    In short, the User enters SUB in Column B to indicate that the previous group is to be subtotaled. Eventually, the code will give the user the ability to add a new group of bars, and to do that, I have to know how many groups already exist. I was hoping to use the COUNTIF function to find the number of times the "SUB" keyword has been entered. To simplify things, I was naming the range and then using it as one of the arguments in the COUNTIF function, but it gives me a Type Mismatch error every time. The arguments for COUNTIF are range and criteria, and it should return a Double. I don't see any obvious problems in my syntax but it bombs out every time I run it.

    Thanks for your time!
    Last edited by Utzja1; 04-18-2016 at 10:06 AM.

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,627

    Re: COUNTIF function giving Type Mismatch error

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)

  3. #3
    Registered User
    Join Date
    10-31-2012
    Location
    Richmond, VA
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: COUNTIF function giving Type Mismatch error

    The problem was in how I was calling the range. the syntax should read:

    Please Login or Register  to view this content.

  4. #4
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,627

    Re: COUNTIF function giving Type Mismatch error

    Thank you for sharing solution.

    This should also work:

    Please Login or Register  to view this content.

+ 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] Concatenate Function getting Type mismatch error
    By capson in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-08-2015, 05:59 PM
  2. [SOLVED] Error 13- "type mismatch" using CountIf function
    By jj4jj in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-21-2015, 07:09 PM
  3. Instr() function giving error: "Type mismatch"
    By arjun.majumdar in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-22-2013, 04:17 AM
  4. VBA Function Generating Type Mismatch Error
    By Mediterranean in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-06-2013, 11:22 AM
  5. Replies: 4
    Last Post: 03-27-2013, 12:16 PM
  6. Iserror is giving me a type mismatch
    By BeefNoodleSoup in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-15-2012, 01:05 AM
  7. Date array function has type mismatch error...
    By secret2 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-21-2011, 02:07 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