+ Reply to Thread
Results 1 to 3 of 3

Macro only works in one spot. Need macro to work on multiple cols and tabs and files.

Hybrid View

  1. #1
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Macro only works in one spot. Need macro to work on multiple cols and tabs and files.

    Hi,

    1. Do the sets of three columns on each sheet always start in the same column & row?
    2. Does the first column in each set of three have any blanks?
    3. If the first column has blanks but the 2nd or 3rd columns don't and hence have more values should the first column include the blanks in the sort?

    Please upload an example workbook.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  2. #2
    Registered User
    Join Date
    09-28-2013
    Location
    San Antonio, Texas
    MS-Off Ver
    Excel 2010
    Posts
    36

    Re: Macro only works in one spot. Need macro to work on multiple cols and tabs and files.

    Answers to your questions:

    1. yes, but there are multiple sets of three columns per sheet, but they all start on the same row and are all of the same size. I need to sort every set of three columns. (sort areas would all begin on row3 of colA, colD, colG, etc. across the sheet on any tab.)
    2. no blanks anywhere within the three columns to be sorted
    3. no blanks anywhere within the three columns to be sorted

    Although the sets of three columns to be sorted are moving across (to the right) on each sheet, all sets are a consistent 3cols X 32rows with no blanks. To simplify things, I am attaching a way cut down version of one of my workbook files. It has three tabs, all of which have three sets of three columns. Each set is already ranked (first column) by the data (third column) but sometimes there are rank ties, so I want to sort by firstcolumn (rank) and secondcolumn (name) in each set to make the ties sort alphabetically. The third column will take care of itself once the sort is made.

    Please note that on the first tab only, I have given an example of what I need as the final result (cols N-V). What I need is a macro I can click on to:
    1) select the desired data range (in my sample file, the first range would be A4:C18) and sort by colA then colB.
    2) then I would like to be able to move my cursor to the top left cell in the next set and click the macro button to sort the next range (D4:F18)
    3) then same for the range G4:I18.
    4) THEN....I want to move to tabs 2 and 3 to do the same sorts on the data sets there.

    I hope that all makes sense. Please let me know if you need more information. Basically, I need to create a macro that will sort a standard size data range anywhere on any file, by the first then second column in the range. A macro that would allow me to sort each set with just one click on a button would save me untold time as the sample I'm attaching is probably only 1% of the size of the data sets I am dealing with. As an additional benefit...I have avoided macros for years but I'm beginning to see what a time saver they are so I really need to learn more about them.
    Thank you very much for your reply and help with this.
    Attached Files Attached Files

+ 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: 3
    Last Post: 02-24-2014, 02:39 PM
  2. [SOLVED] This macro works... kind of. Please spot my error.
    By Alias1431 in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 01-10-2014, 02:31 PM
  3. Replies: 2
    Last Post: 05-06-2013, 06:41 PM
  4. Macro for multiple workbook files and various tabs
    By blondewithbrains in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-05-2011, 05:07 PM
  5. Macro works in Excel, does not work on files opened with Excel
    By mr.alexander in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-09-2009, 04:49 PM

Tags for this Thread

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