Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 115
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 115
Default Refer to a different Worksheet regardless of which Worksheet I'm i

thanks,
worked like a champ
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
refer to last cell in worksheet? svh646 Excel Worksheet Functions 2 July 25th 06 01:23 AM
Refer to more than one worksheet in a workbook Göran M Excel Worksheet Functions 0 January 2nd 06 07:02 AM
variable to refer to "this worksheet"? confused Excel Worksheet Functions 1 June 16th 05 11:51 PM
Refer to Excel Worksheet by its name RichB Excel Worksheet Functions 2 February 5th 05 01:07 PM
Formula to refer to other worksheet... Liz-In-USA Excel Worksheet Functions 4 November 9th 04 10:51 PM


All times are GMT +1. The time now is 05:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"