Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default What is the item "How Many"?

When you need to know howmany, you build the range as bob shows in the sub
Howmany3, and in the macro that needs to know howmany, you call the howmany
function, passing it the range where you want to know howmany. You don't
store the value anywhere - you have it calculated each time you need it.

Regards,
Tom Ogilvy

"Bruce Roberson" wrote in message
...
In this procedure that Bob Phillips helped me come up
with, I think it does its work correctly in that it comes
up with the number of lines in column 1 of a current
region where the value is a 3.

But once the end sub is encountered, isn't this value lost
unless it is saved to a cell somewhere?

The reason I come to that conclusion is when I go through
in debug mode and I put a watch on the variable howmany,
it got the answer, but when the macro is run out, it says
<out of context for the value, and it also
says "variant/Empty" for the type.

So what do I need to do? Do I need to put a statement
before End Sub that stores that value somewhere in a range?
If I can get to this value in another macro during the
same spreadsheet session, then could someone tell me how
to do that part?

Thanks,


Bruce
__________________________________________________ _________

Sub Howmany3()
Dim cRows As Long
cRows = Cells(Rows.Count, Range("Start").Column).End
(xlUp).Row
myNum = Howmany(Range(Cells(1, Range("Start").Column),
Cells(cRows, _
Range("Start").Column)), 3)
End Sub
Function Howmany(rng As Range, val)
Dim cell As Range
Dim cMatch As Long
For Each cell In rng
If cell.Value = val Then
cMatch = cMatch + 1
End If
Next
Howmany = cMatch
End Function




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
Getting "Per Item" Pivot Chart Results when data rows are identica holmansworld Excel Discussion (Misc queries) 4 February 19th 09 06:38 PM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
HELP on "left","right","find","len","substitute" functions serene83 Excel Discussion (Misc queries) 5 June 27th 06 02:23 AM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM


All times are GMT +1. The time now is 03:11 AM.

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"