Horizontal sort of multiple rows

kurt n k

New Member
Joined
Oct 19, 2020
Messages
2
Office Version
  1. 2013
Platform
  1. Windows
I have a set of data consisting of 18 columns with 125 rows. The first column "A" is a text field, and the next 17 columns "B" through R are values. I Need to sort the 17 columns of data from largest to smallest for each of the 125 rows. I don't think that this can be done easily without a macro. I am no expert at writing code. I was hoping that you could help me. Thank you
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
VBA Code:
Option Explicit

Sub sortH()
    Dim lr As Long, i As Long
    Application.ScreenUpdating = False
    lr = Range("A" & Rows.Count).End(xlUp).Row
    For i = 2 To lr
        Range("B" & i & ":R" & i).Sort key1:=Range("B" & i & ":R" & i), Order1:=xlDescending, Orientation:=xlLeftToRight

    Next i
    Application.ScreenUpdating = True

    MsgBox "Completed"
End Sub
 
Upvote 0
VBA Code:
Option Explicit

Sub sortH()
    Dim lr As Long, i As Long
    Application.ScreenUpdating = False
    lr = Range("A" & Rows.Count).End(xlUp).Row
    For i = 2 To lr
        Range("B" & i & ":R" & i).Sort key1:=Range("B" & i & ":R" & i), Order1:=xlDescending, Orientation:=xlLeftToRight

    Next i
    Application.ScreenUpdating = True

    MsgBox "Completed"
End Sub
Thank you so much! That is perfect! I appreciate your assistance.
 
Upvote 0

Forum statistics

Threads
1,215,692
Messages
6,126,228
Members
449,303
Latest member
grantrob

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