Sort a Range of rows Down a column alphabetically

KORKIS2

Board Regular
Joined
Jun 5, 2015
Messages
143
I want the column to be alphabetically organized from top (A) to bottom (z) but I want it to be in a set range of rows that I have previously searched for

I think this is close but it says the sort method is not correct

Range("B2:G10").Select
Selection.sort Key1:=Range("A4"), Order1:=xlAlphabetical, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("R1000").Select
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Key1 refers to the column range in your selection range, not just the header of column. Or you can write just the name if you are using named ranges.

Selection.Sort Key1:=Range("B1:B8"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
 
Upvote 0
I found this from another forum page but can't get it to work

http://www.mrexcel.com/forum/excel-...l-basic-applications-macro-sort-question.html



Code:
Sub SortMe()
 
Dim cell as Range
Dim msg as String
 
Application.ScreenUpdating = False
 
On Error Resume Next
Set Cell = Range("A:A").Find(What:=0, After:=Range("A7"), LookIn:=xlValues, LookAt:=xlWhole)
On Error Goto 0
 
If Not Cell Is Nothing Then
  Range("A7:Z" & Cell.Row - 1).Sort Key1:=Range("A7"), Order1:=xlAscending, Header:=xlGuess
Else
  Application.ScreenUpdating = True
  Msg = "No 0 values found, cannot determine last row of customer"
  Msg = Msg & vbCrLf & vbCrLf & "Macro exiting"
  MsgBox Msg 
  Exit Sub
End If
 
Application.ScreenUpdating = True
 
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,203,620
Messages
6,056,335
Members
444,861
Latest member
B4you_Andrea

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