+ Reply to Thread
Results 1 to 6 of 6

VBA To look for dynamic column header and sort largest to smallest

  1. #1
    Registered User
    Join Date
    07-09-2013
    Location
    Malaysia
    MS-Off Ver
    Excel 2010 64bit
    Posts
    48

    VBA To look for dynamic column header and sort largest to smallest

    In row 1, I have a dynamic column with date (eg. from 1st to 31st) with daily sales data, at the end of column there is a header column "Grand Total", I want to write a script to look for "Grand Total" and do a autofilter or sorting from largest to smallest, below is the code i am working so far with no luck except i got to input manually range.("g1:g5000"), but like i said it's dynamic column the "grand total" column will change everyday, can anyone enlighten me, your help is greatly appreciated, thanks.

    Please Login or Register  to view this content.

  2. #2
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,914

    Re: VBA To look for dynamic column header and sort largest to smallest

    How about this.

    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  3. #3
    Registered User
    Join Date
    07-09-2013
    Location
    Malaysia
    MS-Off Ver
    Excel 2010 64bit
    Posts
    48

    Re: VBA To look for dynamic column header and sort largest to smallest

    Bakerman2,
    Wow your code is working, short and simple, thank you & you're awesome!

  4. #4
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,914

    Re: VBA To look for dynamic column header and sort largest to smallest

    You're welcome and thanks for feedback.

    Also, as a relatively new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

  5. #5
    Registered User
    Join Date
    07-09-2013
    Location
    Malaysia
    MS-Off Ver
    Excel 2010 64bit
    Posts
    48

    Re: VBA To look for dynamic column header and sort largest to smallest

    Done, Thanks again Bakerman2!

  6. #6
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,914

    Re: VBA To look for dynamic column header and sort largest to smallest

    You're welcome and thanks for rep+.

+ 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. [SOLVED] Clear all auto filters and sort column A smallest to largest
    By shj92922 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-19-2019, 07:39 PM
  2. [SOLVED] Sort Last Pivot table column Largest to Smallest
    By 3345james in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-06-2018, 04:55 PM
  3. Replies: 7
    Last Post: 06-20-2016, 08:37 AM
  4. Replies: 1
    Last Post: 04-16-2015, 06:29 PM
  5. How Sort by Largest to Smallest Column by Formula
    By termal in forum Excel General
    Replies: 10
    Last Post: 01-08-2014, 01:17 PM
  6. Sort between bold rows with value of largest to smallest in the fourth column
    By minks in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 06-07-2013, 06:27 PM
  7. Sort Largest to Smallest For Column Pairs
    By bluestarcloudx in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-25-2012, 08:19 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