+ Reply to Thread
Results 1 to 4 of 4

Excel 2010 - VBA - Modify macro to sort Autoformat tables after adding new columns

  1. #1
    Forum Contributor
    Join Date
    11-17-2018
    Location
    Los Angeles
    MS-Off Ver
    Office 2010
    Posts
    234

    Excel 2010 - VBA - Modify macro to sort Autoformat tables after adding new columns

    Excel 2010 - VBA - Modify macro to sort Autoformat tables after adding new columns.

    I need some assistance. Could anyone please help me?

    I have several sheets (called Date1, Date2, etc), and all of them have the same structure: they have at least three Autoformat tables (more are added as needed) and each table "had" three columns. In each sheet there is a macro which sorts all the tables at once for the current sheet. If you open the other sheet and run the macro it will sort all the tables for that other sheet. The macro is stored in it's respective sheet, but it's the same macro.

    Everything was working perfectly up until I needed to add a FOURTH column to each Autoformat table. Then the macro will not work properly and it does (obviously) messes the data.


    The VBA code needs to be modified/adapted so that now it will sort correctly all the tables in the sheet taking into consideration the newly added column. That's it.


    The existing code was originally made so that I could simply add "Tablex2", "Tablex3", "Tablex4"... etc. when new tables were added, but in the original code there were only 3 columns per table always... now there are 4.

    The original columns for each Autoformat table were:

    SEQUENCE 1, SEQUENCE 2, Depth

    The new structure is:

    SEQUENCE 1, SEQUENCE 2, SEQUENCE 3, Depth

    NOTE: Each Autoformat table has a GRAY column (the fourth column as of now, labeled "Depth") which contains a formula. That formula works as expected, but now the macro also messes with hat column.


    The button to run the macro is on column W.


    Here is the code which works flawlessly but only when the tables have three columns.

    Please Login or Register  to view this content.

    In advanced, thank you for any help provided.

    See attached file.

  2. #2
    Valued Forum Contributor
    Join Date
    09-18-2023
    Location
    Geogia, USA
    MS-Off Ver
    365
    Posts
    317

    Re: Excel 2010 - VBA - Modify macro to sort Autoformat tables after adding new columns

    Explaining how the data should be sorted will help others figure out what should be modified.

  3. #3
    Forum Contributor
    Join Date
    11-17-2018
    Location
    Los Angeles
    MS-Off Ver
    Office 2010
    Posts
    234

    Re: Excel 2010 - VBA - Modify macro to sort Autoformat tables after adding new columns

    Oh, oops.

    Sorry.

    The data is being sorter in ascending order... 1, 2, 3, ... by the first column on the left.

    Can the code be modify so that I can easily specify at a later time a different column (within the table, like the second column, or the third. The fourth column will never be used for sorting) if needed? Sort of like it is when I specify which tables to sort...


    No wonder my brother says I'm an airhead.

    I apologize.
    Last edited by Luisftv; 03-31-2024 at 02:24 PM.

  4. #4
    Forum Contributor
    Join Date
    11-17-2018
    Location
    Los Angeles
    MS-Off Ver
    Office 2010
    Posts
    234

    Re: Excel 2010 - VBA - Modify macro to sort Autoformat tables after adding new columns

    I thought of something like this, but it does not work...


    Please Login or Register  to view this content.
    Last edited by Luisftv; 04-01-2024 at 01:40 AM.

+ 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. Replies: 1
    Last Post: 10-08-2019, 02:37 AM
  2. Adding info from two tabs, to a third one using a macro Excel 2010
    By celeazul in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 07-20-2015, 02:34 PM
  3. [SOLVED] Modify Excel 2010 Quick Access Toolbar Macro Icon using VBA
    By unhappyCamper in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-12-2014, 11:46 AM
  4. How to Convert Word 2010 doc to Excel 2010 that contains several tables (one macro)
    By theglitch in forum Word Programming / VBA / Macros
    Replies: 1
    Last Post: 01-24-2013, 01:36 PM
  5. Replies: 3
    Last Post: 02-02-2011, 10:41 AM
  6. [SOLVED] How to modify (or add to) autoformat style?
    By mr_espresso in forum Excel General
    Replies: 1
    Last Post: 07-26-2005, 06:05 PM
  7. [SOLVED] modify autoformat
    By Ashoke in forum Excel General
    Replies: 1
    Last Post: 01-28-2005, 11:06 AM

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