View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
inquirer inquirer is offline
external usenet poster
 
Posts: 74
Default sorting named range

I have defined a named range in vba
srt = Cells(1, i).Value & "_sort"
ActiveWorkbook.Names.Add Name:=srt, RefersTo:=Range(Cells(2, 6),
Cells(lastrow, 6))
where lastrow is 45
How can I use the range to sort the data?
(The worksheet name is "Data")
I have tried
Selection.Sort Key1:=ActiveSheet.Name!srt, Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

but this gives me and Object required error.
Could someone give me the correct way to enter the named range in the
selection command please?
Thanks
CHris