Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
thanks,
worked like a champ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
refer to last cell in worksheet? | Excel Worksheet Functions | |||
Refer to more than one worksheet in a workbook | Excel Worksheet Functions | |||
variable to refer to "this worksheet"? | Excel Worksheet Functions | |||
Refer to Excel Worksheet by its name | Excel Worksheet Functions | |||
Formula to refer to other worksheet... | Excel Worksheet Functions |