Rob wondered if there is a way to count the number of cells containing formulas in a row or column. The answer is quite simple, using the Go To feature of Excel. Follow these steps:

- Display the worksheet for which you want a count.
- Select the row or column in which you want to count formulas.
- Press
**F5**or**Ctrl+G**. Excel displays the Go To dialog box. - Click the Special button. Excel displays the Go To Special dialog box. (See Figure 1.)
- Make sure the Formulas radio button is selected.
- Click OK.

** Figure 1.** The Go To Special dialog box.

That's it. Excel selects all the cells in the row or column that contain formulas. (If you skip step 2, Excel selects all the formulas in the entire worksheet.) At the bottom of the screen, in the status bar, you can see a count of the number of cells selected. (See Figure 2.)

** Figure 2.** The status bar shows a count of selected cells.

If, for some reason, you don't see a count in the status bar, you should check to make sure you have your status bar configured to show counts. Just right-click any blank spot on the status bar and choose Count form the resulting options.

You could also use a formula to figure out how many formulas are in a range of cells, as shown here:

=SUMPRODUCT(--ISFORMULA(A:A))

This example returns the count of all the formulas in column A; you could just as easily substitute a different range of cells in the formula. Whatever range you specify, it should not include the cell where you place this particular formula—that would result in a circular reference and a probable error.

You could also, if desired, use a macro to determine the count. The following example uses the same approach to determining a count as was manually described in the earlier steps:

Sub CountFormulas1() Dim Source As Range Dim iCount As Integer Set Source = ActiveSheet.Range("A:A") iCount = Source.SpecialCells(xlCellTypeFormulas, 23).Count ActiveSheet.Range("D1") = iCount End Sub

This subroutine returns, very quickly, a count of all the formula-containing cells in column A and stuffs that value into cell D1.

It would be very helpful if this approach could be turned into a user-defined function, such as this:

Function CountFormulas2(Source As Range) CountFormulas2 = Source.SpecialCells(xlCellTypeFormulas, 23).Count End Function

This won't work, however. The function always returns the count of the cells in the Source range, not the count of the cells containing formulas. It is an esoteric bug in Excel's VBA that SpecialCells doesn't work in functions; it only works in subroutines. Microsoft hasn't even documented this one (that I can find), thus my reference to it as a "bug" instead of as a "limitation."

There is an actual limitation to what the SpecialCells method can do, however: It can only contain a range of up to 8,192 cells. You can analyze a range that is much larger (as is the case when you have it look at an entire column), but the resulting subset—the resulting range—can only contain up to 8,192 cells. If it contains more, then SpecialCells will "fail" and return a range (and therefore a count) that is equal to the number of cells in the original range.

If you want to create a user-defined function to determine the count, you'll need to rely on something other than the SpecialCells method. Here's an approach that uses the HasFormula property:

Function CountFormulas3(Source As Range) Dim c As Range Dim iCount As Integer iCount = 0 For Each c In Source If c.HasFormula Then iCount = iCount + 1 Next CountFormulas3 = iCount End Function

If you choose to have this macro evaluate an entire column or an entire row, then be prepared to wait a bit—it can take a while for the macro to step through each cell in a column or row. The SpecialCells method is much faster at deriving results than stepping through each cell.

*ExcelTips* is your source for cost-effective Microsoft Excel training.
This tip (13330) applies to Microsoft Excel 2007, 2010, and 2013.

**Program Successfully in Excel!** John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out *Excel 2013 Power Programming with VBA* today!

In a series of values you may need to know the smallest value that isn't a zero. There is no built-in function to do ...

Discover MoreWhen converting between measurement systems, you might want to use two cells for each type of measurement. Make a change ...

Discover MoreNeed to figure out if a value is outside of some arbitrary limit related to a different value? There are a number of ways ...

Discover More**FREE SERVICE:** Get tips like this every week in *ExcelTips,* a free productivity newsletter. Enter your address and click "Subscribe."

2017-07-11 04:02:44

lee

i am trying to use a count function over a range of cells , these cells have a formula already in them but do not actualy update at the same time , because the cells have a formula in them they show a value of 0.00 even though no real data is there, and with this 0.00 figure the count function in the range becomes active, is there anyway around this so the count function only kicks in when the figure is above0.01 or smothing simalar ??

2016-04-14 21:00:55

RS

I want this for a spreadsheet that's backward compatible to Excel 2007. I did notice in Excel 2013, that if I choose Formulas (otherwise known as "Go to Formulas" when the cursor is hovering over this selection in the "Find & Select" menu), it highlights all cells containing formulas and I can easily see the cells that are missing formulas in the range of columns that I'm interested in. I just don't know how to get Excel to give me a count of those rows that are not highlighted that are missing formulas. I'm hoping that although this thread is from 2014, the experts that view this comment will have an easy solution. Thanks!

2014-12-10 05:51:16

In fact, to avoid as the tip says macros taking forever to run you could use as upper bound for your UDF xlLastCell(.Row and .Column), so that you don't try to evaluate a whole column for nothing.

2014-12-09 05:04:52

Michael (Micky) Avidan

If your question refers to: ISFORMULA (the build-in function) the answer is MO.

Michael (Micky) Avidan

“Microsoft® Answers" - Wiki author & Forums Moderator

“Microsoft®” MVP – Excel (2009-2015)

ISRAEL

2014-12-08 13:01:14

Dale

Is there any method for this to work using Excel 2007?

2014-12-08 12:18:49

Michael (Micky) Avidan

There is no need to change the default settings.

Dennis tried to SUM a bunch of True/False but the SUM and/or the SUMPRODUCT is not capable to SUM Booleans - therefor you must change and

the True/False into 1/0, respectively, (This was done in the original tip by using the: --

(Double minus signs).

I like to use the N function.

So:

{=SUM(N(ISFORMULA(A:A)))}

OR:

=SUM(--(ISFORMULA(E3:E25)))

Will work as expected.

Michael (Micky) Avidan

“Microsoft® Answers" - Wiki author & Forums Moderator

“Microsoft®” MVP – Excel (2009-2015)

ISRAEL

2014-12-08 11:13:45

Karthik

However, the UDF solution didn't work for me, when i use =CountFormulas3(A:A)

It returns a '#NAME?' error. Please advise!

2014-12-08 04:21:19

rob

There does seem to be something odd with this scenatio in Excel 2013, Dennis's version doesn't work for me irrespective of the transition setting however the Array Formula

{=SUM(if(ISFORMULA(A:A),1,0))}

does

Rgds R

2014-12-07 14:05:28

Dennis Taylor

The array formula =SUM(ISFORMULA(A:A)) will work only in Excel 2013 and only if you have turned on the setting: Transition formula evaluation.

Go to the File tab in the ribbon and then select Options and then Advanced; the second last box in these options (under Lotus compatibility settings:)is Transition formula evaluation.

Anybody out there have a good reason as to why this is necessary? Is there some strange relationship between Excel and the old Lotus 1-2-3 standards that I'm missing?

2014-12-07 06:53:25

Michael (Micky) Avidan

If it was only for the "slight" difference between a regular formula(SUMPRODUCT) versus an Array formula which is much "heavier" - I would have kept my mouth shut.

BUT - your suggested Array formula (as presented) "doesn't provide the merchandise".

You are welcome to check.

Michael (Micky) Avidan

“Microsoft® Answers" - Wiki author & Forums Moderator

“Microsoft®” MVP – Excel (2009-2015)

ISRAEL

2014-12-06 17:21:49

Dennis Taylor

=SUM(ISFORMULA(A:A))

Be sure to press Ctr+Shift+Enter to complete the entry

2014-12-06 11:42:06

Willy Vanhaelen

ISFORMULA is new to Excel 2013.

2014-12-06 11:16:52

Erik

Got a version of Excel that uses the
ribbon interface (Excel 2007 or later)?
**This site is for you!** If you
use an earlier version of Excel, visit
our *ExcelTips* site focusing on the menu interface.

**FREE SERVICE:** Get tips like this every week in *ExcelTips,* a free productivity newsletter. Enter your address and click "Subscribe."

Copyright © 2018 Sharon Parq Associates, Inc.

## Comments