Range.Sort Sort Method of Range Class Failed

St Jimmy

New Member
Joined
Oct 29, 2015
Messages
37
I think I'm doing something dumb since the solutions I've researched online don't work but I'm trying to sort a dynamic range of cells by their first column.

Code:
Dim LastRow As Integer
Dim LIB As String
LIB = "Library"


Sheets(LIB).Range("A65536").End(xlUp).Select
LastRow = ActiveCell.Row  'Determine last row


Sheets(LIB).Range("A9:R" & LastRow).Sort key1:=Range("A9:A" & LastRow), _
    order1:=xlAcending, Header:=xlNo

I have 4484 rows of data, column A is a text index. AB000100 - AB0014493, no cell in the col A range is empty. There are no duplicates. In the other cells the empty cells are represented by -
All cells are General Category.

When I run the macro it does not sort and spits a run-time error '1004' Sort method of Range class failed.

The data can be sorted manually, but what fun is that? I've never used Range.sort before so I think/hope it's something easy I'm forgetting...

Thank you!!!
 
:oops:
You're quite right Joe, if what I believed was true, it should work, but doesn't.
It seems I've been fed with some duff info. :(
Thanks for that.
 
Upvote 0

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
You're quite right Joe, if what I believed was true, it should work, but doesn't.
It seems I've been fed with some duff info
I thought I heard something like that once too, but I don't remember what language it was about.
Perhaps it was VB and not VBA, or some other programming language?
 
Upvote 0
I thought I heard something like that once too, but I don't remember what language it was about.
Perhaps it was VB and not VBA, or some other programming language?
It was definitely VBA, but I suspect that I may have misunderstood.
It might be that these days it simply uses the same amount of memory regardless of the declaration.
 
Upvote 0

Forum statistics

Threads
1,223,714
Messages
6,174,044
Members
452,542
Latest member
Bricklin

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