+ Reply to Thread
Results 1 to 4 of 4

Filtering macro, count number of rows and include count in last column.

  1. #1
    Registered User
    Join Date
    09-16-2010
    Location
    Glasgow
    MS-Off Ver
    2010
    Posts
    68

    Filtering macro, count number of rows and include count in last column.

    I have a table with 6 columns, columns A to E are populated with data while the last column F is to be used by the macro I would like to implement.

    Basically column A contains a series of numbers, for example range A2 to A9 contains a single number 84260961, I would need a macro to write numbers 1 to 7 in range F2 to F8. Then do the same for the next unique number in column A.

    I assume filtering would be required on column A to only display the first value, then count the number of rows displayed, and finally write the 'filtered' row number in the matching cell of column F.

    Not sure if this makes sense, therefore I have attached a screenshot of what I would like to achieve.

    Filtering Macro.png

    Any help would greatly be appreciated.

    Thanks,
    Ant
    Attached Files Attached Files

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,425

    Re: Filtering macro, count number of rows and include count in last column.

    Why do you need a macro? You could do that with a formula.

    Cell F2: =IF(A2<>A1, 1, N(F1)+1) and drag down.

    You could create a short macro to put that formula in all the cells in column F and then convert to values.


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Filtering macro, count number of rows and include count in last column.

    @Folshot

    Heres what TM was getting at.

    Please Login or Register  to view this content.
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  4. #4
    Registered User
    Join Date
    09-16-2010
    Location
    Glasgow
    MS-Off Ver
    2010
    Posts
    68

    Re: Filtering macro, count number of rows and include count in last column.

    TMS, Mike,

    Thank you very much, that's perfect!

    Ant

+ 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