Macro to sort a range in ascending order

  • Thread starter Thread starter Kerrick Sawyers
  • Start date Start date
K

Kerrick Sawyers

Good Friday morning everyone!

I was hoping that someone could help me with a macro that
I keep getting an error message on. I have a macro that I
need to sort a designated range in ascending order by
column a that reads as follows:
Sub refresh()
Application.Goto Reference:="Acct_Info"
Selection.Sort Key1:=Range("A4"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=True,
Orientation:=xlTopToBottom
End Sub
The macro works fine when I create it, but when I save and
close the file and reopen it, I get an error message that
says "Sort method of range class failed." Does anyone
know what I am doing wrong here. I would appreciate any
assistance you could provide. Thanks!

Kindest regards,

Kerrick Sawyers
 
Hi Kerrick!

Here's one I used today:

Sub Sort_English()
UnProtect
Range("A4:O4").Select
Selection.Interior.ColorIndex = 36
Rows("5:348").Select
Selection.Sort Key1:=Range("B5"), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("B4").Select
Selection.Interior.ColorIndex = 35
Protect
End Sub

Unprotect and Protect are macros that protect sheets in the workbook.
Rows 5:348 is the range to be sorted and does not include the header
in row 4.
The color stuff is to highlight the column which has been the sort
criteria.


--
Regards
Norman Harker MVP (Excel)
Sydney, Australia
(e-mail address removed)
Excel and Word Function Lists (Classifications, Syntax and Arguments)
available free to good homes.
 
Back
Top