How do I make a macro work in one worksheet only
I have the following macro:
ActiveSheet.Unprotect Password:="test" Range("A10:T400").Select Selection.Sort Key1:=Range("B10"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom Range("A1").Select ActiveSheet.Protect Password:="test" My problem is that I only want this macro to work on the worksheet titled "Data Entry Sheet". If somebody accidentally runs it while they are working on a different worksheet it messes up all the formulas on that worksheet. Any and all help is greatly appreciated. Thanks in advance. |
How do I make a macro work in one worksheet only
Hi Hawkfan757
Use this as first line in your macro If ActiveSheet.Name = "Data Entry Sheet" Then Exit Sub -- Regards Ron de Bruin http://www.rondebruin.nl "Hawkfan757" wrote in message ... I have the following macro: ActiveSheet.Unprotect Password:="test" Range("A10:T400").Select Selection.Sort Key1:=Range("B10"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom Range("A1").Select ActiveSheet.Protect Password:="test" My problem is that I only want this macro to work on the worksheet titled "Data Entry Sheet". If somebody accidentally runs it while they are working on a different worksheet it messes up all the formulas on that worksheet. Any and all help is greatly appreciated. Thanks in advance. |
All times are GMT +1. The time now is 06:44 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com