+ Reply to Thread
Results 1 to 10 of 10

Count number of occurrence in column and print to array

  1. #1
    Registered User
    Join Date
    03-03-2011
    Location
    Beaumont, TX
    MS-Off Ver
    Excel 2011 Mac
    Posts
    25

    Count number of occurrence in column and print to array

    I have two columns. First column contains a sorted list of years and the second column contains values for that year.
    E.G.
    Column B Column C
    2001 27-330
    2002 27-330
    2003 27-330
    2003 27-230
    2003 27-230
    2003 27-330
    2003 27-280
    2003 27-250
    2003 27-230
    2003 27-230
    2003 27-230
    2003 27-230
    2003 27-230

    I would like to count the number of occurrences in column C based on Column B and print it to an array format.
    Been able to set up the header and row names, but now need to fill in the array.

    Please help!!

    Master Workbook Rev 9.xlsm

  2. #2
    Registered User
    Join Date
    03-03-2011
    Location
    Beaumont, TX
    MS-Off Ver
    Excel 2011 Mac
    Posts
    25

    Re: Count number of occurrence in column and print to array

    'Bump - No response'

  3. #3
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Count number of occurrence in column and print to array

    With an pivot table.

    See the attached file.
    Attached Files Attached Files
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  4. #4
    Registered User
    Join Date
    03-03-2011
    Location
    Beaumont, TX
    MS-Off Ver
    Excel 2011 Mac
    Posts
    25

    Re: Count number of occurrence in column and print to array

    Quote Originally Posted by oeldere View Post
    With an pivot table.

    See the attached file.
    I like the pivot table idea. How can one write this into a VBA code to automatically populate the table with dynamic rows?

  5. #5
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Count number of occurrence in column and print to array

    Perhaps another way. In F2 and copy down and across.

    =COUNTIFS($B$1:$B$10000,F$1,$C$1:$C$10000,$E2)
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

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

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  6. #6
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Count number of occurrence in column and print to array

    Duplicate post. Sorry.


    The same as usual ...forum issues...

    ...This forum requires that you wait 30 seconds between posts. Please try again in 15 seconds.

    ...and so on...
    Last edited by Fotis1991; 06-10-2013 at 11:56 AM.

  7. #7
    Registered User
    Join Date
    03-03-2011
    Location
    Beaumont, TX
    MS-Off Ver
    Excel 2011 Mac
    Posts
    25

    Re: Count number of occurrence in column and print to array

    Quote Originally Posted by Fotis1991 View Post
    Duplicate post. Sorry.


    The same as usual ...forum issues...

    ...and so on...

    I like the code...
    How can this be written into VBA so that it can be applied dynamically?

  8. #8
    Registered User
    Join Date
    03-03-2011
    Location
    Beaumont, TX
    MS-Off Ver
    Excel 2011 Mac
    Posts
    25

    Re: Count number of occurrence in column and print to array

    Quote Originally Posted by Fotis1991 View Post
    Duplicate post. Sorry.


    The same as usual ...forum issues...

    ...and so on...

    I like the code...
    How can this be written into VBA so that it can be applied dynamically?

  9. #9
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Count number of occurrence in column and print to array

    Please Login or Register  to view this content.
    Why should it be with VBA, when it can be done with built in functions in Excel??

  10. #10
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Count number of occurrence in column and print to array

    VBA is not my forte!

    Just for fun i recorded a macro, but i can't see any reason to use VBA for this..
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    03-03-2011
    Location
    Beaumont, TX
    MS-Off Ver
    Excel 2011 Mac
    Posts
    25

    Re: Count number of occurrence in column and print to array

    Quote Originally Posted by Fotis1991 View Post
    VBA is not my forte!

    Just for fun i recorded a macro, but i can't see any reason to use VBA for this..
    That's pretty cool.

    Gives me a head start.

    Thanks

  12. #12
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Count number of occurrence in column and print to array

    .....................

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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