+ Reply to Thread
Results 1 to 15 of 15

Formula/Function for counting formulas in a range

  1. #1
    Forum Contributor
    Join Date
    05-02-2012
    Location
    Mosselbaai, Suid Afrika
    MS-Off Ver
    Excel 2016
    Posts
    107

    Formula/Function for counting formulas in a range

    Formula or Function for counting formulas in a range for Excel 2003 - 2010:

    Is it possible to count formulas in a range by making use of a formula or function for Excel versions 2003 - 2010?

    Regards,
    Henk Stander

  2. #2
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Formula/Function for counting formulas in a range

    Hi,

    Try this UDF :

    Please Login or Register  to view this content.
    Regards
    1. I care dog
    2. I am a loop maniac
    3. Forum rules link : Click here
    3.33. Don't forget to mark the thread as solved, this is important

  3. #3
    Forum Contributor
    Join Date
    05-02-2012
    Location
    Mosselbaai, Suid Afrika
    MS-Off Ver
    Excel 2016
    Posts
    107

    Re: Formula/Function for counting formulas in a range

    Thanks karedog,
    It is working perfectly.

    I wonder it it would be possible without an UDF as well.

    Regards,
    Henk

  4. #4
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Formula/Function for counting formulas in a range

    You are welcome Henk.

    I think it will be very difficult by using regular formulas. For example, if we try to detect this by checking Left(cell,1) = "=", it is possible that the cell is formatted as text and the cell's content is "=blabla" but this cell is not formula (it is a string), so this method won't work.

    Regards

  5. #5
    Forum Contributor
    Join Date
    05-02-2012
    Location
    Mosselbaai, Suid Afrika
    MS-Off Ver
    Excel 2016
    Posts
    107

    Re: Formula/Function for counting formulas in a range

    @Karedog
    It is possible to use =Cell("type",A1) to distinguish between a formula and text, "l" for " '=3*A3 " and "v" for " =3*A3 ". The problem is that "left" is looking at the result of the formula, i.e. the cell value and not the real content.

    Regards
    Henk

  6. #6
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Formula/Function for counting formulas in a range

    Quote Originally Posted by Henk Stander View Post
    It is possible to use =Cell("type",A1) to distinguish between a formula and text, "l" for " '=3*A3 " and "v" for " =3*A3 ".
    But that function returning "v" does not in any way tell you that that cell contains a formula: it simply gives you information about the datatype of the value returned by that formula.

    In 2013 there is a FORMULATEXT function which might go some way towards offering a non-VBA solution, though beyond that and using e.g. GET.CELL (which is technically a macro anyway, even though it can be called via Name Manager alone) there is no real solution other than with VBA to your query.

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  7. #7
    Forum Contributor
    Join Date
    05-02-2012
    Location
    Mosselbaai, Suid Afrika
    MS-Off Ver
    Excel 2016
    Posts
    107

    Re: Formula/Function for counting formulas in a range

    @XOR LX
    I know, that was to address karedog's concern for differentiating between a formula and text starting with an "=" sign. Unfortunately, as you said, it doesn't tell you whether it is a formula or not.

    Pitty.

    Thanks anyway.

    In 2013 the following formula will work:
    {=SUM(N(ISFORMULA(A:A)))}
    OR:
    =SUM(--(ISFORMULA(A1:A20)))

    Regards,
    Henk

  8. #8
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Formula/Function for counting formulas in a range

    Quote Originally Posted by Henk Stander View Post
    In 2013 the following formula will work:
    {=SUM(N(ISFORMULA(A:A)))}
    OR:
    =SUM(--(ISFORMULA(A1:A20)))
    Indeed, though I certainly wouldn't recommend the first of those (an array formula processed over an entire column's worth of cells is not a good idea!).

    I don't have 2013 yet, though can I infer from these formulas that SUMPRODUCT is not capable of inducing ISFORMULA to operate over an array of values, and so we must use a CSE construction?

    Regards

  9. #9
    Forum Contributor
    Join Date
    05-02-2012
    Location
    Mosselbaai, Suid Afrika
    MS-Off Ver
    Excel 2016
    Posts
    107

    Re: Formula/Function for counting formulas in a range

    I believe =SUMPRODUCT(--ISFORMULA(A:A)) should also work.

    Regards

  10. #10
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Formula/Function for counting formulas in a range

    Quote Originally Posted by Henk Stander View Post
    I believe =SUMPRODUCT(--ISFORMULA(A:A)) should also work.
    Thanks. Though, please, heed my advice about not using entire column references in such constructions! (Unless this is something that has also been addressed in 2013?)

    Regards

  11. #11
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Formula/Function for counting formulas in a range

    I find an article here : http://www.mrexcel.com/forum/excel-q...arguments.html
    that using Get.cell function (an old xl 4 macro function), but it must be used using a named range object (cannot directly put as cell's function).

    Take a look at my sample file.

    Regards
    Attached Files Attached Files

  12. #12
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Formula/Function for counting formulas in a range

    Quote Originally Posted by karedog View Post
    I find an article here : http://www.mrexcel.com/forum/excel-q...arguments.html
    that using Get.cell function (an old xl 4 macro function), but it must be used using a named range object (cannot directly put as cell's function).
    Yes. That's precisely what I said here:

    Quote Originally Posted by XOR LX View Post
    ...using e.g. GET.CELL (which is technically a macro anyway, even though it can be called via Name Manager alone)...
    and so your workbook would need to be macro-enabled (which you don't appear to have done?).

    Regards

  13. #13
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Formula/Function for counting formulas in a range

    Quote Originally Posted by XOR LX View Post
    Yes. That's precisely what I said here:
    You are absolutely right, I just pointed to OP a complete reliable reference with a working example, I hope you don't mind.

    Please Login or Register  to view this content.
    Isn't it an Excel 2003 XLS file ?

    Regards

  14. #14
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Formula/Function for counting formulas in a range

    Quote Originally Posted by karedog View Post
    Isn't it an Excel 2003 XLS file ?
    Sincere apologies. Need to open my eyes.

    Regards

  15. #15
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Formula/Function for counting formulas in a range

    Quote Originally Posted by XOR LX View Post
    Sincere apologies. Need to open my eyes.

    Regards
    No problem at all, we live in a fast world

    Regards

+ 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. Replies: 2
    Last Post: 07-22-2014, 10:30 AM
  2. Replies: 2
    Last Post: 06-25-2014, 11:17 PM
  3. Counting Months in Range Function
    By run2win17 in forum Excel General
    Replies: 2
    Last Post: 04-20-2011, 03:44 PM
  4. Function - Counting Years in range
    By VBA Noob in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-17-2006, 03:00 PM
  5. FORMULA for COUNTING #S STARTING WITH A 4 IN A RANGE 1 TO 100,000
    By dbglass in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-12-2006, 03:35 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