Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 161
Default Counting entries in a range

Hi,

I have an array, defined by:

vNetScore = .Range(.Range("s3"), .Range("s100")).Value

Valid values within this array can be anything between 0 and 25.

I need to count the number of values within sets of sub-ranges in this array:
Number of occurrences of 0-6
Number of occurrences of 7 - 14
Number of occurrences of 15 - 21
Number of occurrences of 22-25

Hope this makes sense!

This is in Office '07 under Vista.

Can anyone provide the code to do this?

TIA

Dave

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Counting entries in a range

Hi,

Here's a sledghammer way

Sub versive()
Set vNetScore = Range("s3:s100")
For Each c In vNetScore

Select Case c.Value
Case Is = 22
twentytwo = twentytwo + 1
Case Is = 14
fifteen = fifteen + 1
Case Is = 7
seven = seven + 1
Case Is = 0
zero = zero + 1
End Select


Next
Debug.Print twentytwo
Debug.Print fifteen
Debug.Print seven
Debug.Print zero
End Sub


Mike

"Risky Dave" wrote:

Hi,

I have an array, defined by:

vNetScore = .Range(.Range("s3"), .Range("s100")).Value

Valid values within this array can be anything between 0 and 25.

I need to count the number of values within sets of sub-ranges in this array:
Number of occurrences of 0-6
Number of occurrences of 7 - 14
Number of occurrences of 15 - 21
Number of occurrences of 22-25

Hope this makes sense!

This is in Office '07 under Vista.

Can anyone provide the code to do this?

TIA

Dave

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 806
Default Counting entries in a range

Hello Dave,

Array-enter into 4 adjacent vertical cells:
=Freq(S3:S100)

Freq is this UDF:
Function freq(r As Range) As Variant
freq = Application.WorksheetFunction.Frequency(r, Array(6, 14, 21,
25))
End Function

Regards,
Bernd
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 entries mexmex Excel Discussion (Misc queries) 2 December 27th 09 01:51 PM
counting entries mits Excel Worksheet Functions 4 August 18th 09 02:11 PM
Counting entries Dos Equis Excel Worksheet Functions 4 November 20th 06 03:24 AM
Counting Entries Jimbo Excel Worksheet Functions 6 April 29th 05 08:27 PM
Counting entries Scott Excel Programming 0 August 21st 03 08:49 PM


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