PDA

View Full Version : Sorting without absolute cell referenes



Sander-
12-05-2007, 04:28 AM
I have a simple question, but did not find it while searching so I'll give it a go:)

I need to sort a list of orders by the customer number. Below is the sort method; it works with absolute cell references (A1:N36) But I can't get it to work using these relative cell references.

The variables are given using e.g.
Row = rfStartcell.Row


With Worksheets("Orderlist")
.Sort.SortFields.Clear
.Sort.SortFields.Add Key:=Range(.Cells(Row, Column), .Cells(Lastrow, Column)), SortOn:=xlSortOnValues, Order:=xlAscending
With Worksheets("Orderlist").Sort
.SetRange Range(.Cells(Row - 1, Column - 2), .Cells(Lastro, Column))
.Header = xlYes
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With

Any ideas?

Bob Phillips
12-05-2007, 06:48 AM
That should work fine. Can you give the full non-working code?