+ Reply to Thread
Results 1 to 6 of 6

COUNTIFS with INDIRECT Formula Problem

  1. #1
    Forum Contributor
    Join Date
    06-08-2012
    Location
    Panama City, FL
    MS-Off Ver
    Excel 2016
    Posts
    175

    COUNTIFS with INDIRECT Formula Problem

    Hello all . . . please help me if you can.

    The following is the formula I am using to retrieve data from a different sheet, CVL is the other SheetName. I don't like having to enter new dates in the formula every time I want to change the quarter from which I am retrieving data. I would merely want to change the date at CVL!F1.
    Please tell me how I need write this for the COUNTIFS Criteria to be that the date(s) must be GREATER THAN the DATE in Cell F2 (on the other sheet named CVL).

    COUNTIFS(INDIRECT("'"&$A$2&"'!$B$5"):INDIRECT("'"&$A$2&"'!$B$900"),">10/1/13")

    Cell A2 is on my current sheet and contains the Name of another sheet, "CVL". I must use the A2 cell location, rather than the name "CVL" because the value in it changes.

    The date in this script (10/1/13) is found in CVL!F1 on that other sheet.

    Thanks!

  2. #2
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: COUNTIFS with INDIRECT Formula Problem

    Try

    COUNTIFS(INDIRECT("'"&$A$2&"'!$B$5"):INDIRECT("'"&$A$2&"'!$B$900"),">" & INDIRECT("'"&$A$2&"'!F1"))

  3. #3
    Forum Contributor
    Join Date
    06-08-2012
    Location
    Panama City, FL
    MS-Off Ver
    Excel 2016
    Posts
    175

    Re: COUNTIFS with INDIRECT Formula Problem

    Thanks Jonmo1. I've tried so many more complicated ways to do it that didn't work.
    I appreciate you showing me the 'easy way.'

    If you don't mind taking another moment . . . will you please EXPLAIN to me how this works?

    INDIRECT("'"&$A$2&"'!F1")

    -- First, why does the entire thing have to be in double-quotes? INDIRECT(" ... ")
    -- Next, why is the local cell in double and single quotes? What's the purpose of all the quotes?
    It seems like it would suffice as this: INDIRECT(" '&$A$2&' !F1")
    -- And finally, why are the "&" on both sides of the $A$2 local address?

    Thanks!

  4. #4
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: COUNTIFS with INDIRECT Formula Problem

    Indirect uses a TEXT string to build a range reference.

    so to get
    CVL!F1

    Put CVL in a cell, say A2
    Then you use concatenate (the & symbol is shorthand for concatenate) to join 2 or more text strings into 1
    =$A$2&"!F1"
    That joined "CVL" with "!F1" to make "CFL!F1"

    Now the extra quotes are not really required in this case because the sheetname in A2 does not contain any spaces.
    In a regular formula, referencing a sheet with spaces in it's name, you have to put ' around that sheetname
    ='Sheet 1'!F1

    So again, it's not actually required in this case because there are no spaces in CVL
    But many choose to do it anyway if it's not required, just to make sure they never forget to put them there when it is required.

    So it becomes
    ="'"&$A$2&"'!F1"
    it joined "'" (thats double quote | single quote | double quote)
    with the text in A2
    and then with "'!F1" (that's double quote | single quote | exclamation | F1
    So the resulting text is
    'CVL'!F1

    Hope that helps.

  5. #5
    Forum Contributor
    Join Date
    06-08-2012
    Location
    Panama City, FL
    MS-Off Ver
    Excel 2016
    Posts
    175

    Re: COUNTIFS with INDIRECT Formula Problem

    Okay, so if I understand this correctly . . . the dbl quotes around &A2& are used to make it text to be concatenated on both ends with something.
    Then, the single quote preceding the text is concatenated with the text and the (single quote, exclamation, F1) are concatenated to the rear of the text, AND
    the entire thing is made TEXT for the INDIRECT FUNCTION by placing double quotes on the outside of the entire value to make a text argument as required for the indirect function.

    Thank you very much for helping me understand this. It'll go a long way in helping me with similar potential problems in the future.
    Have a great day!

  6. #6
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: COUNTIFS with INDIRECT Formula Problem

    Yep, that summed it up well.

    Glad to help.

+ 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] Problem with COUNTIFS formula
    By BeerKing in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-26-2014, 10:19 AM
  2. [SOLVED] problem in countifs formula
    By hello911helpme in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 07-17-2013, 08:14 AM
  3. Countifs formula problem
    By amberj32 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-20-2012, 11:22 AM
  4. COUNTIFS + AND formula problem
    By Kagesen in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-25-2012, 03:30 AM
  5. [SOLVED] Excel 2007 : Problem IF and COUNTIFS formula
    By tiger01 in forum Excel General
    Replies: 2
    Last Post: 02-23-2011, 05:33 AM

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