+ Reply to Thread
Results 1 to 7 of 7

count with a range

  1. #1

    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. #2

    Re: 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. #3

    Re: 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. #4
    Don Guillett
    Guest

    Re: count with a range

    or
    Sub countem()
    x = Application.CountIf(Range("a1:a100"), "y")
    MsgBox x
    End Sub
    --
    Don Guillett
    SalesAid Software
    [email protected]
    <[email protected]> wrote in message
    news:[email protected]...
    >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
    >




  5. #5
    Bob Phillips
    Guest

    Re: count with a range

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

    --
    HTH

    Bob Phillips

    (remove nothere from email address if mailing direct)

    <[email protected]> wrote in message
    news:[email protected]...
    > 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
    >




  6. #6

    Re: count with a range

    thanks that great!!!

    John


  7. #7
    Don Guillett
    Guest

    Re: count with a range

    glad to help

    --
    Don Guillett
    SalesAid Software
    [email protected]
    <[email protected]> wrote in message
    news:[email protected]...
    > thanks that great!!!
    >
    > John
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1