ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Reference Range across Worksheets (https://www.excelbanter.com/excel-programming/432793-reference-range-across-worksheets.html)

BJ

Reference Range across Worksheets
 
In MS Excel Objects Sheet1 (Input) I have the following:

Private Sub CommandButton1_Click()
Sheets("Data").Range("Discounts").Select
Selection.ClearContents
End Sub

Basically I am attempting to select and clear a named range within another
worksheet. I'm getting '1004' error so obviously I'm not calling this
correctly.

Any thoughts? I'm not locked into this format - just my goal of clearing
that named range via the button click from the 'Input' worksheet.

Thanks.



Jacob Skaria

Reference Range across Worksheets
 
Try

Sheets("Data").Range("Discounts").ClearContents

If this post helps click Yes
---------------
Jacob Skaria


"BJ" wrote:

In MS Excel Objects Sheet1 (Input) I have the following:

Private Sub CommandButton1_Click()
Sheets("Data").Range("Discounts").Select
Selection.ClearContents
End Sub

Basically I am attempting to select and clear a named range within another
worksheet. I'm getting '1004' error so obviously I'm not calling this
correctly.

Any thoughts? I'm not locked into this format - just my goal of clearing
that named range via the button click from the 'Input' worksheet.

Thanks.



BJ

Reference Range across Worksheets
 
Thanks Jacob - works great ... why? Why can I 'do' something across
worksheets as opposed to 'selecting' across worksheets?

"Jacob Skaria" wrote:

Try

Sheets("Data").Range("Discounts").ClearContents

If this post helps click Yes
---------------
Jacob Skaria


"BJ" wrote:

In MS Excel Objects Sheet1 (Input) I have the following:

Private Sub CommandButton1_Click()
Sheets("Data").Range("Discounts").Select
Selection.ClearContents
End Sub

Basically I am attempting to select and clear a named range within another
worksheet. I'm getting '1004' error so obviously I'm not calling this
correctly.

Any thoughts? I'm not locked into this format - just my goal of clearing
that named range via the button click from the 'Input' worksheet.

Thanks.



Jacob Skaria

Reference Range across Worksheets
 
You dont need to select a range to clear its contents....For you question
....you need to select the sheet first before selecting the range

Sheets("Data").Select
Range("Discounts").Select
Selection.ClearContents

If this post helps click Yes
---------------
Jacob Skaria


"BJ" wrote:

Thanks Jacob - works great ... why? Why can I 'do' something across
worksheets as opposed to 'selecting' across worksheets?

"Jacob Skaria" wrote:

Try

Sheets("Data").Range("Discounts").ClearContents

If this post helps click Yes
---------------
Jacob Skaria


"BJ" wrote:

In MS Excel Objects Sheet1 (Input) I have the following:

Private Sub CommandButton1_Click()
Sheets("Data").Range("Discounts").Select
Selection.ClearContents
End Sub

Basically I am attempting to select and clear a named range within another
worksheet. I'm getting '1004' error so obviously I'm not calling this
correctly.

Any thoughts? I'm not locked into this format - just my goal of clearing
that named range via the button click from the 'Input' worksheet.

Thanks.




All times are GMT +1. The time now is 02:59 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com