Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Sam Sam is offline
external usenet poster
 
Posts: 699
Default count formulas

What vba procedure can I use to count the number of formulas in a given range?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default count formulas

Sub Macro1()
Dim r As Range
Dim c As Integer
For Each r In Selection
If r.HasFormula Then
c = c + 1
End If
Next
MsgBox (c)
End Sub

Select the range on the worksheet and then run the macro
--
Gary's Student


"Sam" wrote:

What vba procedure can I use to count the number of formulas in a given range?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default count formulas

If you wanted to select the formula cells in a range manually, you could use:

Select the range
edit|Goto|special|check formulas

In code:

Option Explicit
Sub testme()

Dim myCount As Long

myCount = 0
On Error Resume Next
myCount = Intersect(Selection, _
Selection.Cells.SpecialCells(xlCellTypeFormulas)). Cells.Count
On Error GoTo 0

MsgBox myCount

End Sub

The intersect() stuff is useful when there's only one cell selected.

Sam wrote:

What vba procedure can I use to count the number of formulas in a given range?


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
Sam Sam is offline
external usenet poster
 
Posts: 699
Default count formulas

Perfect! Thanks!

"Gary''s Student" wrote:

Sub Macro1()
Dim r As Range
Dim c As Integer
For Each r In Selection
If r.HasFormula Then
c = c + 1
End If
Next
MsgBox (c)
End Sub

Select the range on the worksheet and then run the macro
--
Gary's Student


"Sam" wrote:

What vba procedure can I use to count the number of formulas in a given range?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default count formulas

Hi Sam,

What vba procedure can I use to count the number of formulas in
a given range?


Try:
'=============
Public Sub Tester()
Dim rng As Range
Dim i As Long

Set rng = Range("A1:D50") '<<==== CHANGE

On Error Resume Next
i = rng.SpecialCells(xlCellTypeFormulas).Count
On Error GoTo 0

MsgBox i

End Sub
'<<=============


---
Regards,
Norman

"Sam" wrote in message
...
What vba procedure can I use to count the number of formulas in a given
range?



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
formulas to count dates Brian Excel Worksheet Functions 2 August 27th 09 08:53 PM
Count Formulas Jeff Excel Discussion (Misc queries) 1 October 13th 08 08:40 PM
Count formulas Jessica Excel Discussion (Misc queries) 5 August 30th 07 04:27 PM
count formulas cpy Excel Discussion (Misc queries) 2 October 25th 06 09:42 PM
Using count formulas with '<=' Drummy Excel Discussion (Misc queries) 2 June 5th 06 08:35 AM


All times are GMT +1. The time now is 09:11 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"