Count Formulas

excel_novice01

New Member
Joined
Jan 15, 2014
Messages
3
Is there a way that I can count the number of cells that have a formula?

Cell 1: 5
Cell 2: 8
Cell 3: Sum(a1:a2)
Cell 4: 2
Cell 5: 9
Cell 6: Sum(a4:A5)


I would like a formula that would return 2.
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Is there a way that I can count the number of cells that have a formula?

Cell 1: 5
Cell 2: 8
Cell 3: Sum(a1:a2)
Cell 4: 2
Cell 5: 9
Cell 6: Sum(a4:A5)


I would like a formula that would return 2.

Hi,
Use this:
Code:
Function CountFormulas(Rng As Range)
Dim Cell As Range
For Each Cell In Rng
    If Cell.HasFormula Then
       i = i + 1
    End If
Next
CountFormulas = i
End Function
ZAX
 
Upvote 0
Hi excel_novice01 - Try running the code below and adjusting the Range to suit your needs. You can also use the Find & Select -> GoTo -> Special -> Formulas from the Ribbon and only the cells with formulas will be selected. At the bottom of your sheet the number selected should appear.

Hope this helps.

Code:
Sub CountFormulas()
Dim Count As Long
    Range("A1:D15").Select
    Selection.SpecialCells(xlCellTypeFormulas, 23).Select
    
    Count = Selection.Count
    MsgBox (Count)
    
End Sub
 
Upvote 0
Is there a way that I can count the number of cells that have a formula?

Cell 1: 5
Cell 2: 8
Cell 3: Sum(a1:a2)
Cell 4: 2
Cell 5: 9
Cell 6: Sum(a4:A5)

I would like a formula that would return 2.

Are your "formulas" in cells 3 and 6 real Excel formulas (that is, do you see a leading equal sign in the Formula Bar for those cells) or are they as shown, text, without a leading equal sign (when looked at in the Formula Bar)?
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top