View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Dave Peterson
 
Posts: n/a
Default How many formula

I think there's a slight bug in this.

If the worksheet doesn't have a formula, wscount retains its value from the
previous count.

Option Explicit

Sub CountFormulas()
Dim TotalCount As Long
Dim WSCount As Long
Dim WS As Worksheet
On Error Resume Next
For Each WS In ActiveWorkbook.Worksheets
WSCount = 0 '<-- added
WSCount = WS.UsedRange.SpecialCells(xlCellTypeFormulas).Coun t
TotalCount = TotalCount + WSCount
Next WS
MsgBox "You have " & Format(TotalCount, "#,##0") & " formulas."
End Sub


Chip Pearson wrote:

Only with VBA code.

Sub CountFormulas()
Dim TotalCount As Long
Dim WSCount As Long
Dim WS As Worksheet
On Error Resume Next
For Each WS In ActiveWorkbook.Worksheets
WSCount = WS.UsedRange.SpecialCells(xlCellTypeFormulas).Coun t
TotalCount = TotalCount + WSCount
Next WS
MsgBox "You have " & Format(TotalCount, "#,##0") & " formulas."
End Sub

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

"Andy the yeti" wrote in
message
...
Hi all,

Is there a way to count up how many formulae there are in
workbook across
all the tabs?

Many thanks

Andy


--

Dave Peterson