+ Reply to Thread
Results 1 to 4 of 4

Excel 2007 : quotes and ampersand in Count formula

  1. #1
    Registered User
    Join Date
    02-01-2010
    Location
    Sofia, Bulgaria
    MS-Off Ver
    Excel 2007
    Posts
    42

    quotes and ampersand in Count formula

    Thank you for reading this post.

    I am using a countifs formula using dates where C363 is today() and I am counting all instances in column M that match B5 and are BEFORE today's date. Column C lists dates in chronological order for 2010.

    This formula works fine:

    =COUNTIFS(C2:C358,"<="&C363,M2:M358,B5)

    My questions are,
    1) why do I need quotes around "<=" and
    2) why do I need an ampersand (&) before C363 which contains today() ??

    I'm not asking to explain the logic behind Excel but rather, when is it necessary to use quotes and what does the ampersand actually do?

    I frequently make the error of writing =COUNTIFS(C2:C358,<=C363,M2:M358,B5) and after about 15 minutes, I remember the quotes and ampersand.

    Thank you again.
    Adam

  2. #2
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: quotes and ampersand in Count formula

    Hi Adam,

    I personally hate this syntax and find it confusing as ..., but I guess the reasoning behind it is that you need to construct a text string for the argument. If you only want to compare what's in C363, then you can just put C363 as the parameter, but if you go any fancier than a simple "equal to", you'll have to start the "" and &

    Say if C363 has a number, 333, then

    "<="&C363

    will create
    "<=333"

    You can enter that directly as a parameter, too, but you have to include the "".

    So, in short, the "" are for starting a text string and the & is for concatenating and finishing the string off.

    Does that make it clearer?

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: quotes and ampersand in Count formula

    The COUNTIF is basically accepting strings as criteria, where ranges are used as criteria the values within said cells are the criteria strings.

    So it follows that:

    <=C363

    is not a string whereas:

    "<="&C363

    is a string
    (the <= operator is concatenated with contents of C363 thereby making a string)

    To illustrate further, if C363 contained:

    ="<="&TODAY()

    you could simply use:

    C363

    as the criteria in the COUNTIF given the operator is included in the string being generated in C363.

    Does that help at all ?

  4. #4
    Registered User
    Join Date
    02-01-2010
    Location
    Sofia, Bulgaria
    MS-Off Ver
    Excel 2007
    Posts
    42

    Re: quotes and ampersand in Count formula

    Yes, thank you both for the very clear explanations. Hopefully this will help me remember the syntax next time. Your examples were helpful, too!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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