+ Reply to Thread
Results 1 to 15 of 15

Generate a Cell Count Table

  1. #1
    Registered User
    Join Date
    11-24-2009
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    11

    Generate a Cell Count Table

    Hello There,
    I have a big excel sheet with data in many cells across rows and columns:
    X Y Z
    X X Z
    T V V
    Z V V

    What i wanted to do is generate a list of cells with count as

    V 4
    Z 3
    X 3
    T 1
    Y 1

    Can someone point me in the right direction, thanks.

  2. #2
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Generate a Cell Count Table

    Let your range of data is in sheet1
    the results will end in sheet2

    mind the starting row in sheet1

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    11-24-2009
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: Generate a Cell Count Table

    Thanks RCM this is exactly what i was thinking. I am facing issue though, i think your script is only counting the first three columns, i want to make it so it counts all where there is text, as i have some rows with 10 columns some with 16, some with 25 etc
    Last edited by ginjack; 07-03-2016 at 05:15 PM.

  4. #4
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Generate a Cell Count Table

    Dear ginjack:

    The inner loop scoops data until there is none so there can be variable number of columns

  5. #5
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Generate a Cell Count Table

    look at sample with variable number of columns
    Attached Files Attached Files

  6. #6
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Generate a Cell Count Table

    I think that this will do what you want
    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  7. #7
    Registered User
    Join Date
    11-24-2009
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: Generate a Cell Count Table

    Thanks RCM, i tried. script works as expected, but the values are incorrect.
    For example, if i search for the same keyword in excel, i get only 2 results
    but the script counted it as 79 results.
    I thought maybe script is picking up entries around it, but no number is near to the result i got by manually testing (2)
    Is there something that i am overlooking?

  8. #8
    Registered User
    Join Date
    11-24-2009
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: Generate a Cell Count Table

    Quote Originally Posted by mikerickson View Post
    I think that this will do what you want
    Please Login or Register  to view this content.
    Thanks Mike, i tried running the script but it keeps crashing my excel, i have about 1million cells of data, and a strong laptop but i guess it isn't able to process it.
    RCM's solution works, but is giving me incorrect number counts

  9. #9
    Registered User
    Join Date
    11-24-2009
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: Generate a Cell Count Table

    Hi RCM, i have attached my output for sample, please check 1st entry, count shows there are 5, but there are only 2 results in Excel sheet.
    i think somewhere, calculation is giving an error
    Attached Files Attached Files

  10. #10
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Generate a Cell Count Table

    Here is the sub. It works on the sample. could you send a larger sample?
    Please Login or Register  to view this content.

  11. #11
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Generate a Cell Count Table

    Ok I improved it and came up with this version
    Attached Files Attached Files

  12. #12
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Generate a Cell Count Table

    This should be easier on your computer's memory, but slower.
    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    11-24-2009
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: Generate a Cell Count Table

    Thanks Mike, but its still crashing excel rightaway. It processes for about 30 seconds and becomes non responding and closes.

    -
    RCM, your script works fine and runs completely, just the count that it gives is incorrect, i've testing it multiple times my batch and smaller batches, but it's still giving wrong numbers.

    The error is due to, some of my fields have + in them. for example 20+ Green, 15+ Red, and i think that is breaking the script, as script adding that number multiple times. Could that be possible?
    Last edited by ginjack; 07-10-2016 at 07:57 PM.

  14. #14
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Generate a Cell Count Table

    Try this
    Please Login or Register  to view this content.

  15. #15
    Registered User
    Join Date
    11-24-2009
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: Generate a Cell Count Table

    Quote Originally Posted by jindon View Post
    Try this
    Please Login or Register  to view this content.
    Thanks Jindon,
    this worked perfectly, and it did it in about 3 seconds.
    The other script codes were taking about 30mins + and still crashing.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Macro to compare the data between 2 files and generate the count
    By Manish_Gupta in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-25-2014, 07:03 AM
  2. [SOLVED] How do I get an entry in one table to generate the rows in an additional table?
    By Gavalar in forum Word Formatting & General
    Replies: 4
    Last Post: 04-16-2014, 08:07 PM
  3. How to generate table from cumulative table?
    By pejaemma25 in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 04-10-2014, 02:16 AM
  4. [SOLVED] How do you count a cell in table with formulas
    By Jarvin24 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-15-2013, 04:35 AM
  5. Replies: 2
    Last Post: 12-14-2012, 01:17 PM
  6. Row Count in Table = Cell Value
    By dch27 in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 07-27-2009, 09:00 AM
  7. Using Macro to link sql table to generate Pivot Table
    By Benard in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-22-2008, 06:02 AM

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