Consulting

Results 1 to 6 of 6

Thread: Excel Count Macro

  1. #1
    VBAX Newbie
    Joined
    Jul 2017
    Posts
    3
    Location

    Excel Count Macro

    Hi,

    I have an excel 2016 spreadsheet with about 1000 rows of data. Each row has a name like ***_type1, or ***_type2, or ***_type3, etc. They also have further subdivisions, another column has a number (1,2,3,4, etc.) I would like to keep track of how many rows of each type the spreadsheet has and also how many are within each subdivision.

    For example if the spreadsheet contains 100 rows of type1, I would like it to show on a separate sheet that I have 100 rows of type1 and 20 are in subdivision 1, 30 are in subdivision 2, 50 are in subdivision 3.

    Does anybody have a macro that could do this or know a way I could make this happen?

    Thank you!

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Add a column to list each type and then create a pivot table. Post a sample if you need further assistance.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    VBAX Newbie
    Joined
    Jul 2017
    Posts
    3
    Location
    Quote Originally Posted by mdmackillop View Post
    Add a column to list each type and then create a pivot table. Post a sample if you need further assistance.
    Thank you mdmackillop for the response I didn't think of that.

    So I created a new column with a formula that would strip the beginning part of the name to use for the pivot table. Shown below.

    =REPLACE(C2,1,FIND("_",C2),"")

    C2 is where the name is held. The only problem I had here was that in some of the names there are multiple underscores so the formula would only remove the first instance. So something like ***_type12 would work fine but ***_***_type12 would not. Do you know a better way to do this?

  4. #4
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    =SUBSTITUTE(RIGHT(C2,6),"_","")
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  5. #5
    VBAX Newbie
    Joined
    Jul 2017
    Posts
    3
    Location
    Thanks this is exactly what I was looking for!

  6. #6
    VBAX Newbie
    Joined
    Aug 2017
    Posts
    1
    Location
    I have been searched the way to solve this problem for a long time.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •