Results 1 to 4 of 4

COUNTIF function giving Type Mismatch error

Threaded View

  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:

    Sub NextGroup()
    
    Dim b As Double
    
    Range("B1:B100").Name = "SUBcol"
    
    b = WorksheetFunction.CountIf("SUBcol", "SUB")
    
    End Sub
    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.

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