+ Reply to Thread
Results 1 to 10 of 10

count blank cells only if a 1 is previous

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    10-24-2008
    Location
    England
    Posts
    146

    count blank cells only if a 1 is previous

    Hi
    I need help getting a formula to do this
    I have
    ......D E
    5 )......1
    6 )......2
    7 )......3
    8 )......4
    9 )......5
    10)......6
    11)......7
    etc down to 31

    They only show up when the cell next to it is not empty.
    =IF(ISBLANK(D5),"0",(1))
    =IF(ISBLANK(D6),"0",(2))
    etc

    If nothing is put into say D5 D6 or D7 but something is put in D8 then i would like E8 to become 1 as it is the first to be filled.Then when D9 has something in it, it becomes 2
    if D10 has nothing in it it gets left blank but when d11 has something in it e11 becomes 4 counting the blank cell in between.
    How can this be done.

    Any help would be great
    Thanks
    Last edited by Directlinq; 02-20-2009 at 04:58 AM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: count blank cells only if a 1 is previous

    How about:

    =IF(ISBLANK(D6),0,E5+1)

    No "quotes" around numbers. Copy that down, it should do what you wanted.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Contributor
    Join Date
    10-24-2008
    Location
    England
    Posts
    146

    Re: count blank cells only if a 1 is previous

    This works but if a cell is skipped it starts from 1 again and does not count the blank cell.

    ......D E
    5 )......1
    6 )......2
    7 )......3
    8 )......4
    9 )......5
    10)......6
    11)......7
    etc down to 31

    If D10 has nothing in it E10 gets left blank but when d11 has something in it E11 becomes 4 counting the blank cell in between.

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: count blank cells only if a 1 is previous

    Quote Originally Posted by Directlinq View Post
    This works but if a cell is skipped it starts from 1 again and does not count the blank cell.

    ......D       E
    5             1 
    6             2
    7             3
    8             4
    9             5
    10            6
    11            7
    etc down to 31
    If D10 has nothing in it E10 gets left blank but when d11 has something in it E11 becomes 4 counting the blank cell in between.
    If you put [code] tags around stuff it will line up legibly.

    Looking at your sample above, there is no clear reason why E11 would be 4?

  5. #5
    Forum Contributor
    Join Date
    10-24-2008
    Location
    England
    Posts
    146

    Re: count blank cells only if a 1 is previous

    .....D        E
    5    1        1 
    6    1        2
    7    1        3
    8    1        4
    9    1        5
    10   1        6
    11   1        7
    etc down to 31
    If D5 D6 and D7 are left blank i would like this to happen which it does with this formula
    =IF(ISBLANK(D6),0,E5+1)

    .....D        E
    5             0 
    6             0
    7             0
    8    1        1
    9    1        2
    10   1        3
    11   1        4
    etc down to 31
    If D5 D6 D7 and D10 has nothing in it E10 gets left blank but when d11 has something in it E11 becomes 4 counting the blank cell in between.

    example 1
    .....D        E
    5             0 
    6             0
    7             0
    8    1        1
    9    1        2
    10            3
    11   1        4
    etc down to 31
    example 2
    .....D        E
    5    1        1
    6             2
    7             3
    8    1        4
    9    1        5
    10            6
    11   1        7
    etc down to 31
    example 3
    .....D        E
    5             0
    6             0
    7    1        1
    8             2
    9    1        3
    10            4
    11   1        5
    etc down to 31
    the counting starts from the first 1 in the E column

    Sorry about the confusion.
    Many Thanks

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: count blank cells only if a 1 is previous

    will it always be 1s in that column D?

  7. #7
    Forum Contributor
    Join Date
    10-24-2008
    Location
    England
    Posts
    146

    Re: count blank cells only if a 1 is previous

    No 1 is just an example of that cell being filled (notblank)
    Thank you

  8. #8
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: count blank cells only if a 1 is previous

    so isn't it just

    E5: = N(E4)+(COUNTA(D$5:D5)>0)

  9. #9
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: count blank cells only if a 1 is previous

    in reality... to avoid COUNTA repeatedly looking at the same range over and over...

    E5: =N(E4)+OR(N($E4),D5<>"")

  10. #10
    Forum Contributor
    Join Date
    10-24-2008
    Location
    England
    Posts
    146

    Re: count blank cells only if a 1 is previous

    Perfect spot on
    Thank you

+ 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