View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Cone[_2_] Jim Cone[_2_] is offline
external usenet poster
 
Posts: 1,549
Default Sort macro error


key1 needs a range object.
Columns(sKey) or Range(sKey) may work, depending on what sKey returns.
--
Jim Cone
Portland, Oregon USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



wrote in message
Can anyone help me with this? I keep getting a "Reference is not
valid" error 1004, and I can't figure out why. I've used the sort code
before and it worked fine. Now... No clue.

sKey is a reference to a cell, user picks the field from a drop down
and it enters the field value in the sKey source cell

LastRow is a function Ron de Bruin shared with me to find the last row
containing data

Ultimately, it is the segment for sorting that is "out of sorts".

Here's the code:

If sKey 0 Then
DestSh.Select
Last = LastRow(DestSh)
Range("A4:AZ" & Last).Select

Selection.Sort key1:=sKey, Order1:=xlAscending, Header:=xlNo,
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Else
End If


Thank you!

Steven