![]() |
Refer to a different Worksheet regardless of which Worksheet I'm i
I have 2 Worksheets in my Workbook: Program_Data_Input & Program_Summary
In the Macro I have a line: Range("A3:G300").Select Selection.ClearContents This clears fine when I am on the Program_Data_Input Woorksheet. I never want to update the Program_Summary Worksheet (I've protected it just in case). If I were on the Program_Summary Worksheet and ran the macro there by mistake (set to Ctrl+i) is there a way to hard code the macro to explicitly clear the Program_Data_Input Worksheet regardless of which Worksheet I'm in? I tried using this instead but got an error: Worksheets("Program_Data_Input").Range("A3:G300"). Select Selection.ClearContents |
Refer to a different Worksheet regardless of which Worksheet I'm i
Hi C,
Try:: Worksheets("Program_Data_Input").Range("A3:G300"). ClearContents Selections atr rarely necessary. Additionally, attempting to select a range on a sheet other than the active sheet will cause a run-time error. --- Regards, Norman "CRayF" wrote in message ... I have 2 Worksheets in my Workbook: Program_Data_Input & Program_Summary In the Macro I have a line: Range("A3:G300").Select Selection.ClearContents This clears fine when I am on the Program_Data_Input Woorksheet. I never want to update the Program_Summary Worksheet (I've protected it just in case). If I were on the Program_Summary Worksheet and ran the macro there by mistake (set to Ctrl+i) is there a way to hard code the macro to explicitly clear the Program_Data_Input Worksheet regardless of which Worksheet I'm in? I tried using this instead but got an error: Worksheets("Program_Data_Input").Range("A3:G300"). Select Selection.ClearContents |
Refer to a different Worksheet regardless of which Worksheet I'm i
In the macro you need to say e.g.
thisworkbook.sheets("Mysheet").range("a3:g300").cl earcontents It will only empty the cells in the workbook where the macro is in (=thisworkbook). Wolf "CRayF" wrote: I have 2 Worksheets in my Workbook: Program_Data_Input & Program_Summary In the Macro I have a line: Range("A3:G300").Select Selection.ClearContents This clears fine when I am on the Program_Data_Input Woorksheet. I never want to update the Program_Summary Worksheet (I've protected it just in case). If I were on the Program_Summary Worksheet and ran the macro there by mistake (set to Ctrl+i) is there a way to hard code the macro to explicitly clear the Program_Data_Input Worksheet regardless of which Worksheet I'm in? I tried using this instead but got an error: Worksheets("Program_Data_Input").Range("A3:G300"). Select Selection.ClearContents |
Refer to a different Worksheet regardless of which Worksheet I'm i
thanks,
worked like a champ |
All times are GMT +1. The time now is 12:04 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com