Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Counting Cells that meet criteria across entire workbook


I am looking to write a macro that checks each cell in each sheet in
workbook and counts the occurences of formulas. I am not sure how t
approach this. The code below prints all the sheets in a workbook.
It dimensions "s" as a Worksheet. Is it possible to use the sam
thinking for what I want to do? That is, can you dimension a variabl
as a cell (or range), check to see that it meets a condition, and kee
adding this to a cumulative total that summarizes the result in
message box?

Sub PrintAll()
Dim s As Worksheet
For Each s In Worksheets()
s.Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Next s

End Sub

Thank

--
ExcelMonke
-----------------------------------------------------------------------
ExcelMonkey's Profile: http://www.excelforum.com/member.php...nfo&userid=522
View this thread: http://www.excelforum.com/showthread.php?threadid=26821

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Counting Cells that meet criteria across entire workbook

Sub CountAll()
Dim s As Worksheet
Dim cell as Range
Dim cnt as Long
cnt = 0
For Each s In Worksheets()
for each cell in s.UsedRange
if isnumeric(cell) then
if cell.Value 100 then
cnt = cnt + 1
end if
end if
Next cell
Next s
Msgbox "Number found is " & cnt
End Sub

If you are actually counting against a simple criteria, you would probably
want to use CountIF or Sumif against the usedrange. More explanation, more
help.

--
Regards,
Tom Ogilvy


"ExcelMonkey" wrote in message
...

I am looking to write a macro that checks each cell in each sheet in a
workbook and counts the occurences of formulas. I am not sure how to
approach this. The code below prints all the sheets in a workbook.
It dimensions "s" as a Worksheet. Is it possible to use the same
thinking for what I want to do? That is, can you dimension a variable
as a cell (or range), check to see that it meets a condition, and keep
adding this to a cumulative total that summarizes the result in a
message box?

Sub PrintAll()
Dim s As Worksheet
For Each s In Worksheets()
s.Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Next s

End Sub

Thanks


--
ExcelMonkey
------------------------------------------------------------------------
ExcelMonkey's Profile:

http://www.excelforum.com/member.php...fo&userid=5221
View this thread: http://www.excelforum.com/showthread...hreadid=268211



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
Counting # of cells with that meet criteria in two columns Scott at Medt. Excel Worksheet Functions 7 September 19th 07 09:49 PM
Counting Consecutive Cells that meet Criteria Omega Point Excel Discussion (Misc queries) 2 February 26th 06 08:28 PM
Counting lines that meet TWO criteria sam Excel Worksheet Functions 2 January 31st 06 09:04 PM
Counting cells that meet 2 differnet criteria USChad Excel Worksheet Functions 1 September 7th 05 07:58 PM
Counting Values that meet another cells criteria Jess Excel Worksheet Functions 1 March 8th 05 01:42 AM


All times are GMT +1. The time now is 02:03 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"