Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
extend selected CurrentRegion results in application or objectdefined error 1004
Hi
I've tried many work-arounds & read many posts - it's probably something simple so please bare with this learner. please help with the correct syntax for these lines: 'tbl.Offset(0, 0).Resize(tbl.Rows(0), tbl.Columns(2)).Select & '.Offset(0, -2).Select I have CurrentRegion selected (A to I, variable rows) I want to custom sort on K which contains a UDF which inserts the colour index of col G (no problems with this part) J is empty (when I tried the UDF in J the index value & sort kept messing up - #Value) & then re-select the original CurrentRegion so that I can set the print range. Sub SortByColourWorkLog() Dim tbl As Range ' 'sorts on =ColorIndexOfCell(G2) function in mod 1 ' Application.Volatile Selection.CurrentRegion.Select Set tbl = ActiveCell.CurrentRegion 'tbl.Offset(0, 0).Resize(tbl.Rows(0), tbl.Columns(2)).Select '(error occuring here) Selection.Sort Key1:=Range("K2"), Order1:=xlDescending, Key2:=Range("H2") _ , Order2:=xlAscending, Header:=xlYes, OrderCustom:=7, MatchCase:=False _ , Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2:= _ xlSortNormal '.Offset(0, -2).Select '(want to re-select the original "CurrentRegion") ActiveSheet.PageSetup.PrintArea = Selection.CurrentRegion End Sub Cheers again Peta |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
runtime error '1004' application or object defined error | Excel Programming | |||
runtime error '1004' application or object defined error. Please help | Excel Programming | |||
Run Time Error 1004: Application or Object Defined Error | Excel Programming | |||
Error 1004, Application-definded or object-defined error | Excel Programming | |||
run-time error '1004': Application-defined or object-deifined error | Excel Programming |