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

Hi and thank you in advance.

I'm trying to count the word "Standard" in a series of ranges. Say A10-A15,
then maybe A40-A43...it keeps changing from 3 rows upto 10 rows.

Is there anyway to count in a range when the range keeps changing in the
amount of rows. Like it won't ever be only 5 rows, it may be 3 rows, 6 rows,
9 rows and then 2 rows.

Any help is greatly appreciated.

Thank you again.

Tim

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default Counting in a variable range

Select the range you wish to count in

run this procedure to display a messagebox with the result

:======================================

Sub CountInSelection()

MsgBox Application.WorksheetFunction.CountIf(Selection, "Standard")

End Sub

:======================================

else declare a variable to th result and use as you wish. Let me know
if you need any more help for you use.

http://www.excel-ant.co.uk

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Counting in a variable range

Piece together the sections and then count within the union:

Sub example()
Dim r, rr As Range
Dim countit As Integer
Set r = Union(Range("A10:A15"), Range("A40:A43"))
countit = 0
For Each rr In r
If rr.Value = "Standard" Then
countit = countit + 1
End If
Next
MsgBox (countit)
End Sub

Alternatively, you can select the areas in the worksheet and then:

For Each rr in Selection


--
Gary's Student


"Tim" wrote:

Hi and thank you in advance.

I'm trying to count the word "Standard" in a series of ranges. Say A10-A15,
then maybe A40-A43...it keeps changing from 3 rows upto 10 rows.

Is there anyway to count in a range when the range keeps changing in the
amount of rows. Like it won't ever be only 5 rows, it may be 3 rows, 6 rows,
9 rows and then 2 rows.

Any help is greatly appreciated.

Thank you again.

Tim

  #4   Report Post  
Posted to microsoft.public.excel.programming
Tim Tim is offline
external usenet poster
 
Posts: 408
Default Counting in a variable range

Thank you both for your response...I am working with your code now, it has
given me what I needed!

Thank you very very much! You guys are awsome!

"Tim" wrote:

Hi and thank you in advance.

I'm trying to count the word "Standard" in a series of ranges. Say A10-A15,
then maybe A40-A43...it keeps changing from 3 rows upto 10 rows.

Is there anyway to count in a range when the range keeps changing in the
amount of rows. Like it won't ever be only 5 rows, it may be 3 rows, 6 rows,
9 rows and then 2 rows.

Any help is greatly appreciated.

Thank you again.

Tim

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 variable ranges and auto-summing variable ranges Father Guido[_5_] Excel Programming 2 March 29th 06 04:07 AM
Counting Variable Length of Rows in a Named Range jandre[_2_] Excel Programming 0 October 28th 04 06:26 PM
Counting Variable Length of Rows in a Named Range jandre[_3_] Excel Programming 0 October 28th 04 06:24 PM
Counting Variable Length of Rows in a Named Range jandre Excel Programming 1 October 28th 04 05:27 PM
setting a range variable equal to the value of a string variable Pilgrim Excel Programming 2 July 1st 04 11:32 PM


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