Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Norman... Sorry Biff... I wasn't explicit with my referencing...
-- HTH... Jim Thomlinson "Norman Jones" wrote: Hi Jim, Sub Macro2() Application.ScreenUpdating = False Sheets("Sheet3").Columns("A:B").Sort Key1:=Range("B1"), Header:=xlYes, Application.ScreenUpdating = True End Sub I think that there is a subtle problem with this in that, as written, the sort key refers to the activesheet. I think you meant something like: Sub Macro2() Dim sh As Worksheet Set sh = ActiveWorkbook.Sheets("Sheet3") Application.ScreenUpdating = False sh.Columns("A:B").Sort Key1:=sh.Range("B1"), _ Order1:=xlAscending ', _ Header:=xlGuess, OrderCustom:=1, _ MatchCase:=False, _ Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal Application.ScreenUpdating = True End Sub --- Regards, Norman "Jim Thomlinson" wrote in message ... Try avoiding the select(s) something like this. Sub Macro2() Application.ScreenUpdating = False Sheets("Sheet3").Columns("A:B").Sort Key1:=Range("B1"), Header:=xlYes, Application.ScreenUpdating = True End Sub -- HTH... Jim Thomlinson "Biff" wrote: Hi folks! I have this simple macro created using the recorder: Sub Macro2() Application.ScreenUpdating = False Sheets("Sheet3").Select Columns("A:B").Select Selection.Sort Key1:=Range("B1"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal Sheets("Sheet2").Select Application.ScreenUpdating = True End Sub All it does is sort Sheet3 A:B I have the macro assigned to a button on another sheet. It works fine except that after it runs and I go to sheet3 the sorted range, columns A:B, are still selected. How can I get the sorted range to be unselected after the macro runs? Thanks! Biff |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
unselect cells | Excel Discussion (Misc queries) | |||
unselect cells | Excel Discussion (Misc queries) | |||
Unselect Option Box | Excel Discussion (Misc queries) | |||
Unselect a Cell?????? | Excel Programming | |||
Unselect Filtre .... | Excel Programming |