Auto Ranking

V

VoxBox-Richard

I have written some code to sort some data every time its sheet is open. My
code is working fine in 2007, but I am getting errors in 2000.

Can some one look through and give me some pointers.

Thank you.
R.

Code:

Private Sub Worksheet_Activate()

Range("B13").CurrentRegion.sort Key1:=Range("B13"), _
Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=True, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

End Sub
 
J

john

I think the problems is this line "DataOption1:=xlSortNormal" it's not
compatibal with xl2k. Try removing it!
 
P

Peter T

As John says DataOption1 is n/a in xl2000. Following should work in all
versions

Dim oRng As Object ' don't change to as range !

Set oRng = Range("B13")
If Val(Application.Version) <= 10 Then
oRng.CurrentRegion.Sort Key1:=Range("B13"), _
Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=True, Orientation:=xlTopToBottom
Else
oRng.CurrentRegion.Sort Key1:=Range("B13"), _
Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=True, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End If

Regards,
Peter T
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top