Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sort macro error
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable | Excel Worksheet Functions | |||
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable | Excel Discussion (Misc queries) | |||
Programed sort generates error: originated as recorded macro | Excel Programming | |||
Sort error | Excel Discussion (Misc queries) | |||
Macro / Sort error | Excel Programming |