+ Reply to Thread
Results 1 to 11 of 11

Count Column A only up to last nonblank cell in Column B

  1. #1
    Registered User
    Join Date
    06-25-2011
    Location
    Manila, Philippines
    MS-Off Ver
    Excel 2003
    Posts
    16

    Count Column A only up to last nonblank cell in Column B

    I need to count the number of days in column A with the condition of last nonblank cell in Column B. In the ex. below the answer should return 18.



    Column A Column B
    7/1/2011
    7/2/2011 0.70612
    7/3/2011
    7/4/2011 0.6942
    7/5/2011
    7/6/2011 0.70612
    7/7/2011
    7/8/2011
    7/9/2011
    7/10/2011 0.70142
    7/11/2011
    7/12/2011
    7/13/2011
    7/14/2011
    7/15/2011
    7/16/2011
    7/17/2011
    7/18/2011 0.6956
    7/19/2011
    7/20/2011
    7/21/2011
    7/22/2011
    7/23/2011
    7/24/2011
    7/25/2011
    7/26/2011
    7/27/2011
    7/28/2011
    7/29/2011
    7/30/2011
    7/31/2011
    Last edited by katsuya; 07-21-2011 at 07:30 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    05-23-2011
    Location
    Lahore PK
    MS-Off Ver
    Excel 2007, 2013
    Posts
    627

    Re: Count Column A only up to last nonblank cell in Column B

    Try it

    =count(a1:indirect("a"&match(9.99999999999999e+307,b:b)))

  3. #3
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,592

    Re: Count Column A only up to last nonblank cell in Column B

    Maybe this:

    =LOOKUP(99^99, B:B, A:A)-A1+1

  4. #4
    Forum Expert Colin Legg's Avatar
    Join Date
    03-30-2008
    Location
    UK
    MS-Off Ver
    2003, 2007, 2010, 2013
    Posts
    1,252

    Re: Count Column A only up to last nonblank cell in Column B

    Assuming each cell always steps by 1 day:

    =MATCH(9.99E+307,B1:B31)-ROW(B1)+1
    Hope that helps,

    Colin

    RAD Excel Blog

  5. #5
    Registered User
    Join Date
    06-25-2011
    Location
    Manila, Philippines
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: Count Column A only up to last nonblank cell in Column B

    Yes, thanks Azam and zbor. Both nailed it. I guess, I'll use zbor's because my excel IQ is low. Don't know what indirect combined in a range indicate.
    @Colin Legg formula returns 1 cell short. What's with 9.99E+307?

    Many, many thanks guys.
    Last edited by katsuya; 07-21-2011 at 04:43 AM.

  6. #6
    Forum Expert Colin Legg's Avatar
    Join Date
    03-30-2008
    Location
    UK
    MS-Off Ver
    2003, 2007, 2010, 2013
    Posts
    1,252

    Re: Count Column A only up to last nonblank cell in Column B

    What's with 9.99E+307?
    9.99E307, 99^99, 9.99999999999999e+307 -- these are all just very large numbers - larger than any value you're going to have in column B.
    @Colin Legg formula returns 1 cell short
    It returns 18 for me.

  7. #7
    Registered User
    Join Date
    06-25-2011
    Location
    Manila, Philippines
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: Count Column A only up to last nonblank cell in Column B

    ^Yeah it did return ok. How about -Row(B1)? I thought that was part of the range.
    Actual range is A6:A36 for dates and B6:B36 for data. B1 returns the last nonblank cell in B6:B36.
    Many thanks. Very informative though I will just really copy the formula even though I have yet to absorb why it works.

  8. #8
    Forum Expert Colin Legg's Avatar
    Join Date
    03-30-2008
    Location
    UK
    MS-Off Ver
    2003, 2007, 2010, 2013
    Posts
    1,252

    Re: Count Column A only up to last nonblank cell in Column B

    How about -Row(B1)?
    That's a reference to the first cell in the range. So if your range is B6:B36 then you'd use -ROW(B6). But, I think Zbor's formula will suit your needs better (it subtracts the first date from the last date thus giving a date difference in days, as opposed to counting the number of rows)?

  9. #9
    Registered User
    Join Date
    06-25-2011
    Location
    Manila, Philippines
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: Count Column A only up to last nonblank cell in Column B

    Thanks. What's the formula for returning July 18? The date of last nonblank cell in column B.

  10. #10
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,592

    Re: Count Column A only up to last nonblank cell in Column B

    This:

    =LOOKUP(99^99, B:B, A:A)

  11. #11
    Registered User
    Join Date
    06-25-2011
    Location
    Manila, Philippines
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: Count Column A only up to last nonblank cell in Column B

    Many thanks zbor. Big help. Thanks!

+ 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