![]() |
Why does this not work?
First the following macro works when run from with in the "Data Base"
sheet. But when I paste this code in Private Sub Worksheet_Activate() for the Data Base sheet I get an error 1004 on the range("b2:d325).select Why? Sub Macro1() ScreenUpdating = False Sheets("Data Base").Select Range("B2:D325").Select Selection.Sort Key1:=Range("C2"), Order1:=xlAscending, Key2:=Range("B2") _ , Order2:=xlAscending, Key3:=Range("D2"), Order3: =xlAscending, Header:= _ xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom Range("B2").Select Sheets("First Name").Select ScreenUpdating = True End Sub |
Why does this not work?
Hi Pete
are you sure that the line of code range("b2:d325).select actually IS range("b2:d325").select as your code, as posted, in the example runs fine for me. and you do realise that using this code means that no one can ever see the Database sheet, don't you. Cheers JulieD "Pete" wrote in message ... First the following macro works when run from with in the "Data Base" sheet. But when I paste this code in Private Sub Worksheet_Activate() for the Data Base sheet I get an error 1004 on the range("b2:d325).select Why? Sub Macro1() ScreenUpdating = False Sheets("Data Base").Select Range("B2:D325").Select Selection.Sort Key1:=Range("C2"), Order1:=xlAscending, Key2:=Range("B2") _ , Order2:=xlAscending, Key3:=Range("D2"), Order3: =xlAscending, Header:= _ xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom Range("B2").Select Sheets("First Name").Select ScreenUpdating = True End Sub |
Why does this not work?
Hard to tell, but if you are using the Activate event, you shouldn't be
activating sheet within that event. Sub Macro1() ScreenUpdating = False With Sheets("Data Base") Range("B2:D325").Sort Key1:=.Range("C2"), _ Order1:=xlAscending, Key2:=.Range("B2"), _ Order2:=xlAscending, Key3:=.Range("D2"), _ Order3:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, _ Orientation:=xlTopToBottom End With ScreenUpdating = True End Sub -- Regards, Tom Ogilvy "Pete" wrote in message ... First the following macro works when run from with in the "Data Base" sheet. But when I paste this code in Private Sub Worksheet_Activate() for the Data Base sheet I get an error 1004 on the range("b2:d325).select Why? Sub Macro1() ScreenUpdating = False Sheets("Data Base").Select Range("B2:D325").Select Selection.Sort Key1:=Range("C2"), Order1:=xlAscending, Key2:=Range("B2") _ , Order2:=xlAscending, Key3:=Range("D2"), Order3: =xlAscending, Header:= _ xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom Range("B2").Select Sheets("First Name").Select ScreenUpdating = True End Sub |
All times are GMT +1. The time now is 01:57 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com