+ Reply to Thread
Results 1 to 5 of 5

Counting with zero between it and start over if..

  1. #1
    Forum Contributor
    Join Date
    01-17-2011
    Location
    amsterdam, Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    189

    Counting with zero between it and start over if..

    Count how many times you buy something, without selling it
    The difficult part is that there are also zero values between it
    So you buy at A2, A7 and A11. And then at B11 you sell something.
    So you count at C2 is1 at A7 is 2 and A 11 is 3

    Every time you buy something you have to count how many times you bought something without selling it.

    If you sold something you are going to start all over. So at A12 you start over with counting, this one you sell so is only 1

    At A14 you are going to start all over with counting till A24
    The right asnwers are in column C but I have to automate it for a really large sheet
    Can someone please help me!
    Attached Files Attached Files
    Last edited by keis386; 04-15-2011 at 09:51 AM.

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

    Re: Counting with zero between it and start over if..

    Maybe this (with one helper coplumn)...
    Attached Files Attached Files

  3. #3
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Counting with zero between it and start over if..

    I was thinking the answer would be something like this:

    =SUM($A$2:A2)-SUM($B$2:B2) in C2 copied down

    but it doesn't fit in with your example and having read it half a dozen times I really don't get it. How come if you have bought 3 and sold 1 the count is 3?

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  4. #4
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Counting with zero between it and start over if..

    Using your posted example, try this:

    C2: =IF(A2,A2,"")

    and use this regular formula for the rest
    Please Login or Register  to view this content.

    Copy that formula down as far as you need.

    Is that something you can work with?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  5. #5
    Forum Contributor
    Join Date
    01-17-2011
    Location
    amsterdam, Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    189

    Re: Counting with zero between it and start over if..

    Dom, You first buy it on that day and the same day you sell it.

+ 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