Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 104
Default count with a range

I have a range that i have set as myrng
this range is A1:a100, in this range i have either a "n" or a "y" in
each cell, how can i use code to count all the y's within this range

john

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default count with a range

Hello John,

you can make a for each loop und test if the value is y or n.

For each vItem in myrng
if vItem = "y" then count = count +1
next vItem

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 104
Default count with a range

is there a way of doing it without looping i have seen a previous post
which used
count=countwords(myrng,"y"), but this does not seem to work

regards

John

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default count with a range

count = Application.COUNTIF(myrange,"y")

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

wrote in message
oups.com...
is there a way of doing it without looping i have seen a previous post
which used
count=countwords(myrng,"y"), but this does not seem to work

regards

John



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default count with a range

or
Sub countem()
x = Application.CountIf(Range("a1:a100"), "y")
MsgBox x
End Sub
--
Don Guillett
SalesAid Software

wrote in message
oups.com...
I have a range that i have set as myrng
this range is A1:a100, in this range i have either a "n" or a "y" in
each cell, how can i use code to count all the y's within this range

john





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 104
Default count with a range

thanks that great!!!

John

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default count with a range

glad to help

--
Don Guillett
SalesAid Software

wrote in message
oups.com...
thanks that great!!!

John



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
Count Vaules in a range that appear in another range T Newbery Excel Worksheet Functions 5 February 11th 10 05:08 PM
COUNT BETWEEN A RANGE AND Dave Excel Discussion (Misc queries) 8 May 21st 09 04:20 PM
Multiple Criteria, Count If, Sum Product to get count across range Jonathan Excel Worksheet Functions 5 January 9th 08 11:32 PM
How to count dates within a certain range in a column with mutiple date range entries Krisjhn Excel Worksheet Functions 2 September 1st 05 01:59 PM
Count cells in one range based on parameters in another range dave roth Excel Worksheet Functions 2 March 29th 05 05:33 PM


All times are GMT +1. The time now is 01:46 PM.

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

About Us

"It's about Microsoft Excel"