+ Reply to Thread
Results 1 to 6 of 6

Using countif function across workbooks

  1. #1
    Registered User
    Join Date
    10-20-2013
    Location
    New York
    MS-Off Ver
    Excel 2007
    Posts
    3

    Smile Using countif function across workbooks

    Hi,
    First time post here.

    I'm new to VBA and must be doing something simple wrong here.

    I need to use a COUNTIF function in VBA across two workbooks (it needs to be a function in VBA- I can't just type the formula in Excel because I use variables within the filename from which I take the range).

    So the range is within the workbook starting "MStoGTR", within Col C of sheet "SCB_ACKd".
    The criteria is in the active sheet, one cell to the left (FYI: I plan to later drag the COUNTIF down in that column).

    Thanks in advance!
    Rich

    Please Login or Register  to view this content.

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: Using countif function across workbooks

    Hi and welcome to the forum

    Im not sure about using countif() in VBA (not my strong side), but I do know that you cannot use countif() that you cannot use countif() across worksheets and it wont work on closed workbooks
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    10-20-2013
    Location
    New York
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Using countif function across workbooks

    Hi FDibbins
    Thanks for your reply. I'm new to VBA so still trying to understand the functions, so really appreciate the help!
    I know you can use countif across worksheets and workbooks as a formula in Excel - are you 100% sure you can't do the same in VBA?
    Thanks again.

  4. #4
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Using countif function across workbooks

    works mostly the same in vba as in cells. your code oughta be
    Please Login or Register  to view this content.
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  5. #5
    Registered User
    Join Date
    10-20-2013
    Location
    New York
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Using countif function across workbooks

    Thanks Josie. Sorry to be a pain, but when I use your code I receive:

    Compile error:
    Expected: =

    Am I missing a "=" sign somewhere?

  6. #6
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Using countif function across workbooks

    I assumed you were doing something with the result of the function but you didn't say what. if you want to assign it to a cell for instance
    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. Countif multiple criteria across workbooks
    By Lizziesdj in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-08-2013, 06:53 AM
  2. [SOLVED] Countif across workbooks
    By vivekmartin in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 06-13-2013, 01:24 PM
  3. Countif between two workbooks!
    By RadioX in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-22-2012, 01:42 PM
  4. Using Countif Function with the Month & Year Function
    By laya1024 in forum Excel General
    Replies: 3
    Last Post: 02-03-2009, 07:52 PM
  5. Linking workbooks within =countif formula
    By Degauss007 in forum Excel General
    Replies: 0
    Last Post: 04-19-2007, 04:49 PM

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