Sort multiple columns on sheet into A-Z

surkdidat

Well-known Member
Joined
Oct 1, 2011
Messages
597
Office Version
  1. 365
Hi

I have headers in Row 1, and pairs of data in columns (A&B, C&D, E&F all the way to FSS&FST). (Data from Row 4 to Row 1000 - not all rows will go down to row 1000, some will only ave one match, some will have 100, some could have 500 etc)

The data starts in row 4.

What I need it to do is sort the columns in alphabetical order, retaining the pair value for all 2285 pairs.

PRESENT DATA
Column A Column B Column CColumn D
Row 1COLOUR-ENGCOLOUR-FRSHAPE-ENGSHAPE-FR
Row 2(DATA HELD HERE - NOT TO BE MOVED)(DATA HELD HERE - NOT TO BE MOVED)(DATA HELD HERE - NOT TO BE MOVED)(DATA HELD HERE - NOT TO BE MOVED)
Row 3(DATA HELD HERE - NOT TO BE MOVED)(DATA HELD HERE - NOT TO BE MOVED)(DATA HELD HERE - NOT TO BE MOVED)(DATA HELD HERE - NOT TO BE MOVED)
Row 4 (Beginning of data)BlueBleuRoundArrondi
Row 5YellowJauneSquareCarré
Row 6RedRougeArchArc
Row 7GreenVertPyramidPyramide


RESULT

Column AColumn BColumn CColumn D
Row 1COLOUR-ENGCOLOUR-FRSHAPE-ENGSHAPE-FR
Row 2(DATA HELD HERE - NOT TO BE MOVED)(DATA HELD HERE - NOT TO BE MOVED)(DATA HELD HERE - NOT TO BE MOVED)(DATA HELD HERE - NOT TO BE MOVED)
Row 3(DATA HELD HERE - NOT TO BE MOVED)(DATA HELD HERE - NOT TO BE MOVED)(DATA HELD HERE - NOT TO BE MOVED)(DATA HELD HERE - NOT TO BE MOVED)
Row 4BlueBleuArchArc
Row 5GreenVertPyramidPyramide
Row 6RedRougeRoundArrondi
Row 7YellowJauneSquareCarré
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Try this:
VBA Code:
Sub SortData()
    Dim col As Long
    Dim dataRange As Range
    Dim sortRange As Range
    
    Set dataRange = Range("A1").CurrentRegion
    For col = 1 To dataRange.Columns.Count Step 2
        Set sortRange = Range(Cells(4, col), Cells(Rows.Count, col).End(xlUp))
        ActiveSheet.Sort.SortFields.Clear
        ActiveSheet.Sort.SortFields.Add2 Key:=sortRange, _
            SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
        With ActiveSheet.Sort
            .SetRange sortRange.Resize(sortRange.Rows.Count, 2)
            .Header = False
            .MatchCase = False
            .Orientation = xlTopToBottom
            .SortMethod = xlPinYin
            .Apply
        End With
    Next
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,224,755
Messages
6,180,758
Members
452,996
Latest member
nelsonsix66

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top