+ Reply to Thread
Results 1 to 8 of 8

Count number of cells in a range with amount > 0

  1. #1
    Forum Contributor
    Join Date
    06-23-2005
    Posts
    253

    Count number of cells in a range with amount > 0

    What would be the simplest code to get a count of the number of cells in a range F4:F63 that contains an amount greater then zero?

    Thanks so much.

    mikeburg

  2. #2
    Bob Phillips
    Guest

    Re: Count number of cells in a range with amount > 0

    =COUNTIF(F4:F643,">0")

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "mikeburg" <[email protected]> wrote in
    message news:[email protected]...
    >
    > What would be the simplest code to get a count of the number of cells in
    > a range F4:F63 that contains an amount greater then zero?
    >
    > Thanks so much.
    >
    > mikeburg
    >
    >
    > --
    > mikeburg
    > ------------------------------------------------------------------------
    > mikeburg's Profile:

    http://www.excelforum.com/member.php...o&userid=24581
    > View this thread: http://www.excelforum.com/showthread...hreadid=386450
    >




  3. #3
    David Jessop
    Guest

    RE: Count number of cells in a range with amount > 0

    Hi,

    Try

    =COUNTIF(F4:F63,">0")

    HTH,

    David Jessop

    "mikeburg" wrote:

    >
    > What would be the simplest code to get a count of the number of cells in
    > a range F4:F63 that contains an amount greater then zero?
    >
    > Thanks so much.
    >
    > mikeburg
    >
    >
    > --
    > mikeburg
    > ------------------------------------------------------------------------
    > mikeburg's Profile: http://www.excelforum.com/member.php...o&userid=24581
    > View this thread: http://www.excelforum.com/showthread...hreadid=386450
    >
    >


  4. #4
    Bernie Deitrick
    Guest

    Re: Count number of cells in a range with amount > 0

    Mike,

    Dim i As Integer
    i = Application.WorksheetFunction.CountIf(Worksheets("Sheet1").Range("F4:F63"), ">0")
    MsgBox i

    or you can leave out the worksheetfunction part, and the variable:

    MsgBox Application.CountIf(Worksheets("Sheet1").Range("F4:F63"), ">0")


    HTH,
    Bernie
    MS Excel MVP


    "mikeburg" <[email protected]> wrote in message
    news:[email protected]...
    >
    > What would be the simplest code to get a count of the number of cells in
    > a range F4:F63 that contains an amount greater then zero?
    >
    > Thanks so much.
    >
    > mikeburg
    >
    >
    > --
    > mikeburg
    > ------------------------------------------------------------------------
    > mikeburg's Profile: http://www.excelforum.com/member.php...o&userid=24581
    > View this thread: http://www.excelforum.com/showthread...hreadid=386450
    >




  5. #5
    Forum Contributor
    Join Date
    06-23-2005
    Posts
    253

    Count each row with amts in F4:F63 AND text in G4:G63

    Works great, Bernie, for one worksheet.

    However, I have another that I need to count, if range F4:F63 contains an amount greater than zero AND if the corresponding row of G4:G63 contains a text string.

    Any ideas?

    In other words I need a count of the rows whose cells F4:F63 are greater than zero AND whose cells G4:g63 contains text too.

    I am new to VBA, so I really appreciate everyone helping me out. I learn a lot from this!

    mikeburg

  6. #6
    Bob Phillips
    Guest

    Re: Count number of cells in a range with amount > 0

    =SUMPRODUCT(--(F4:F63>0),--(NOT(ISNUMBER(G4:G63))))

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "mikeburg" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Works great, Bernie, for one worksheet.
    >
    > However, I have another that I need to count, if range F4:F63 contains
    > an amount greater than zero AND if the corresponding row of G4:G63
    > contains a text string.
    >
    > Any ideas?
    >
    > In other words I need a count of the rows whose cells F4:F63 are
    > greater than zero AND whose cells G4:g63 contains text too.
    >
    > I am new to VBA, so I really appreciate everyone helping me out. I
    > learn a lot from this!
    >
    > mikeburg
    >
    >
    > --
    > mikeburg
    > ------------------------------------------------------------------------
    > mikeburg's Profile:

    http://www.excelforum.com/member.php...o&userid=24581
    > View this thread: http://www.excelforum.com/showthread...hreadid=386450
    >




  7. #7
    Bernie Deitrick
    Guest

    Re: Count number of cells in a range with amount > 0

    Mike,

    In VBA, you could use

    Dim i As Integer
    i = Application.Evaluate("SumProduct((F4:F63 > 0)* IsText(G4:G63))")
    MsgBox i

    HTH,
    Bernie
    MS Excel MVP


    "mikeburg" <[email protected]> wrote in message
    news:[email protected]...
    >
    > Works great, Bernie, for one worksheet.
    >
    > However, I have another that I need to count, if range F4:F63 contains
    > an amount greater than zero AND if the corresponding row of G4:G63
    > contains a text string.
    >
    > Any ideas?
    >
    > In other words I need a count of the rows whose cells F4:F63 are
    > greater than zero AND whose cells G4:g63 contains text too.
    >
    > I am new to VBA, so I really appreciate everyone helping me out. I
    > learn a lot from this!
    >
    > mikeburg
    >
    >
    > --
    > mikeburg
    > ------------------------------------------------------------------------
    > mikeburg's Profile: http://www.excelforum.com/member.php...o&userid=24581
    > View this thread: http://www.excelforum.com/showthread...hreadid=386450
    >




  8. #8
    Forum Contributor
    Join Date
    06-23-2005
    Posts
    253

    Works great Bernie! Thanks a million!

    Works great Bernie!

    Thanks a million,

    mikeburg

+ 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