+ Reply to Thread
Results 1 to 9 of 9

counting cells in a column with specific data

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    04-18-2009
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    161

    counting cells in a column with specific data

    I want it to count and fill in a range in column A until it sees a blank or notices the change in value in column B. In the example below i hope it shows what i need to do. i left the last group without numbers to show that is where it needs to start counting over again. i am basically wanting to count down 1st place 2nd place etc.... in divisions i designate for tournaments i manage. thanks for your time.

    
    
       A           B        C                 D
        1        mpo       john           doe
        2        mpo       jane            doe
        3        mpo       jim              doe
    
        1       mam       mickey          mouse
        2       mam       daffy            duck
        3       mam       elmer             fudd
    
    
                wam       smith            judy
                wam       wygul           beth
                wam       francis          monica
    Last edited by Traymond; 06-10-2009 at 02:55 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: counting cells in a column with specific data

    Manually, you could do this with a formula. In A1, put 1. In B1 and copied all the way down, put this:

    =IF(B2="","",N(A1)+1)

    Now, if row1 actually has column titles, you could just use that same formula from first row of data all the way down, don't need to enter the 1 to start it.
    _________________
    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
    04-18-2009
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    161

    Re: counting cells in a column with specific data

    I can be dumber than a bag of rocks sometimes. i attached a sample file. could you fill that in so i can see how to do it. i guess i am confused.
    thanks
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    04-18-2009
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    161

    Re: counting cells in a column with specific data

    Jbeaucaire... i tried the manual code but it is not adding the plus one. it puts all ones in. it does skip the blanks. any suggestions
    
    1
    1
    1
    
    1
    1
    1
    
    1
    1
    1

  5. #5
    Forum Contributor
    Join Date
    04-18-2009
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    161

    Re: counting cells in a column with specific data

    never mind ..... i figured out what i was doing wrong. thanks so much for the help. you have always given me the right answer or solutions. i hope to pass on what i am learning from you experts.

  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: counting cells in a column with specific data

    ...and the same approach built into a macro:
    Option Explicit
    
    Sub AddCount()
    Dim LR As Long
    LR = Range("B" & Rows.Count).End(xlUp).Row
    
    Range("A1") = 1       'Delete this line if row 1 is column titles
    
    Range("A2:A" & LR).FormulaR1C1 = "=IF(RC2="""","""",N(R[-1]C)+1)"
    Columns(1).Value = Columns(1).Value
    
    End Sub

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

    Re: counting cells in a column with specific data

    Your workbook doesn't match the sample chart you posted, you shifted everything over by one column and I imagine you didn't adjust anything in the formula

    Put this in B7 and copy down:

    =IF(C7="","",N(B6)+1)

    Or use the adjusted macro (based on your sample sheet):
    Sub AddCount()
    Dim LR As Long
    LR = Range("C" & Rows.Count).End(xlUp).Row
    
    Range("B7:B" & LR).FormulaR1C1 = "=IF(RC3="""","""",N(R[-1]C)+1)"
    Columns(2).Value = Columns(2).Value
    
    End Sub

  8. #8
    Forum Contributor
    Join Date
    04-18-2009
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    161

    Re: counting cells in a column with specific data

    Perfect !!!!!!! dang i wish i had your knowledge.

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

    Re: counting cells in a column with specific data

    The more I use Excel, the more I realize I have so much to learn. It's a monster.

+ 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