Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA code sort problems - recorded macro does not work with userform
Hi
I need to sort a range of cells to put in numerical order. I recorded a macro but when I transfered it to my userform button I hit problems The following code sorts but I get a runtime error 13 type mismatch when I exit the userform. When I debug it has failed when it should be loading another userform Sub Mysort1() Sheets("Lists").Select Range("CM38:CM42").Select Selection.Sort Key1:=Range("CM38"), Order1:=xlAscending, Header:=xlGuess _ , OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal End Sub I tried removing the selection part and used Sheets("Lists").Range("CM38:CM42").Sort Key1:=Range("CM38"), Order1:=xlAscending, Header:=xlGuess _ , OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal This time sorting does not take place and I get runtime 1004 The sort reference is not valid. Make sure that it's within the data you want to sort, and the first SortBy box isn't the same or blank I have searched the web but have not found a solution Can anyone see what I am doing wrong. Kenny XP pro and office 2003 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Recorded Macro Problems | Excel Worksheet Functions | |||
Programed sort generates error: originated as recorded macro | Excel Programming | |||
Newbie-question: recorded macro does not work - why? | Excel Programming | |||
looking to simplify a recorded macro with code | Excel Programming | |||
flip an autoshape using VBA- recorded macro doesn't work | Excel Programming |