+ Reply to Thread
Results 1 to 10 of 10

Vba for sort data then total

  1. #1
    Forum Contributor
    Join Date
    01-29-2012
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    434

    Vba for sort data then total

    Hello

    We need a vba solution for my problem.. which is that .. we have a large data more then 49000 roads.. which is unsorted data..
    We want this data to sort then totling also with following condition

    Sort Data
    First sort Assembly (COLUM C) then sort Nature of Works (COLUMN J)
    then sort District (COLUMN B)

    after sorting se need also TOTALING with first Nature of Works (COLUMN J) then Assembly (COLUM C) and then District (COLUMN B)

    we have 3 type nature of work (PATCH, RENEWAL & SR),, in a assembly possible all type nature of work,, may be 1 type work may bhi 2 type work...
    In a district possible many Assembly.. with different name.. (maximum 10) we want Assembly Total and in Last we want District Total..

    We can sort this with Sort option in excel but.. we dont know how to 3 type total done automatically in excel .. so we need to vba solution..
    my sample data is also attach with output what we want

    Thanks in adavance..

    Santosh
    Attached Files Attached Files

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Vba for sort data then total

    Hi Santosh,

    You can use the custom sort feature. Right click on your data >> Sort >> Custom Sort

    Under Sort by >> Column C
    Add Level >> Column J etc

    If you want a macro...

    For the sort, try...

    Please Login or Register  to view this content.
    For the Totaling part, look into using a pivot table.

    BTW, your attachment could be corrupted as I could not open it.
    HTH
    Regards, Jeff

  3. #3
    Forum Contributor
    Join Date
    01-29-2012
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    434

    Re: Vba for sort data then total

    hello jeff .. thank for ur respoce.. and advice.. actualy ur current provided code only sort.. not totaling.. as per my need...

    well i m not knowing much more about pivot table option ...so we need vba...

    we are enclosing my new file hope this will b open..

    Thanks for ur reply..

    Santosh
    Attached Files Attached Files

  4. #4
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Vba for sort data then total

    Hello Santosh,

    Like I indicated, I could not open your original file for some reason, so didn't actually understand the layout until now.

    Sorry, not sure I have a VBA solution for that layout. I would look into a pivot table still, but it's going to take some investigation on your part to figure out the correct layout which works for you. Pivot tables have a myriad of option and layouts.

  5. #5
    Forum Contributor
    Join Date
    01-29-2012
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    434

    Re: Vba for sort data then total

    Hi Jeff.. well don't know why my sample file not open ur end..
    any way thanks for valuable suggestion.. we are trying to find some vba code with this forum or googling..

    hope any other expert will look this matter..

    thanks again jeff..
    we add rep..

  6. #6
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Vba for sort data then total

    Thanks for the rep Santosh and I have reached out to others for some additional possible ideas...

  7. #7
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: Vba for sort data then total

    I've got to head out now. But this should get you started. It will give you subtotal by categories you wanted (plus 2 Grand Total rows).
    When I get back or may be tomorrow I will take a look at formatting etc.

    Please Login or Register  to view this content.
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  8. #8
    Forum Contributor
    Join Date
    01-29-2012
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    434

    Re: Vba for sort data then total

    Hi ck sir ur provided code working as per my need.. only 2 thing more 1 formating issue and 2nd Serial Number issue..
    hope this will also solve in this vba..

    Thanks for ur valuabel code..

  9. #9
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Vba for sort data then total

    Try this...

    At the end of the code in post #7, add a Call to the sub below. If you want to change some of the colors around, look at the link in the code and adjust the number and the end of the .ColorIndex

    Please Login or Register  to view this content.
    Last edited by jeffreybrown; 06-03-2017 at 11:33 AM.

  10. #10
    Forum Contributor
    Join Date
    01-29-2012
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    434

    Re: Vba for sort data then total

    hi ck sir and jef sir with both off contribute we got solution
    thank

+ 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. Sort data and calculate total time
    By john55 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-05-2017, 01:26 PM
  2. Replies: 12
    Last Post: 03-16-2016, 02:00 PM
  3. How to find sort & sub total data from a table with some condition
    By tpsdas in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 01-06-2015, 12:08 PM
  4. Replies: 1
    Last Post: 04-18-2014, 05:54 PM
  5. [SOLVED] Macro to sort data by column B within the Location & Total rows?.
    By ludsonline in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-23-2013, 06:04 AM
  6. [SOLVED] Macro to sort data, insert a line after each group & then total?
    By karinmpfa in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-24-2006, 08:15 PM
  7. Sort And Total
    By travelersway in forum Excel General
    Replies: 2
    Last Post: 07-23-2005, 12:25 PM

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