+ Reply to Thread
Results 1 to 2 of 2

I want to sort 2 different columns automatically in one sheet

  1. #1
    Registered User
    Join Date
    11-22-2021
    Location
    NZ
    MS-Off Ver
    2016
    Posts
    1

    Question I want to sort 2 different columns automatically in one sheet

    I am currently using the the formula
    Private Sub Worksheet_Change(ByVal Target As Range)
    'Updateby Extendoffice
    On Error Resume Next
    If Application.Intersect(Target, Application.Columns(1)) Is Nothing Then Exit Sub
    If Target.Count > 1 Then Exit Sub
    Range("A1").Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlYes, _
    OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
    End Sub

    This only works to auto sort column A in the worksheet function not in the module part. I want to then use this same formula to auto sort column B as a secondary sort. Can someone give me some instructions regarding this.
    Thank you

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: I want to sort 2 different columns automatically in one sheet

    This will do what you ask. But...........

    You might find it annoying. Type something in A5 and press tab to get into B5 the range sorts,
    You have to find where B5 has sorted to and type the second value.

    Please Login or Register  to view this content.



    This version sorts when you change B5 but only if A5 has data

    Please Login or Register  to view this content.

    Another Version. Lets you enter data in A then B. Or B then A. It only runs when both cells have data.

    Please Login or Register  to view this content.
    Last edited by mehmetcik; 11-22-2021 at 08:52 PM.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

+ 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] Vba, Automatically Sort 3 columns Alphabetically
    By (T_T) in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-21-2020, 10:59 AM
  2. VBA/Macro to Automatically Update, Copy, & Sort information from Sheet 1 to Sheet 2
    By E9demello in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-10-2017, 09:37 AM
  3. Automatically Sort data in three columns when I update column E (Protected Sheet)
    By pwhittak in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-09-2016, 08:12 AM
  4. VBA To Sort 2 Columns Automatically
    By dustind8721 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-27-2015, 12:34 PM
  5. [SOLVED] How to automatically sort the columns (move the columns around)
    By OldGrantonian in forum Excel General
    Replies: 4
    Last Post: 08-18-2013, 07:44 AM
  6. [SOLVED] Automatically Sort Columns
    By HeatherV in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 11-12-2012, 04:33 PM
  7. Automatically sort new data by multiple columns
    By burtonlang in forum Excel General
    Replies: 3
    Last Post: 10-26-2009, 08:03 AM

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