Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
ade ade is offline
external usenet poster
 
Posts: 16
Default Delete cells not in Active Worksheet

I use the following code to delete cells from the Active Worksheet,

Range("A2", Cells(Rows.Count, "A")).Clear

this works fine but when I try to delete cells from a different sheet in my
Workbook I get 'Application-defined or Object-defined Error'.
The code which gives this error is,

Worksheets("NotInStock").Range("A2", Cells(Rows.Count, "A")).Clear

any suggestions as to what is wrong with the code?
Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Delete cells not in Active Worksheet

You need to fully qualify the Cells reference:

With Worksheets("NotInStock")
.Range("A2", .Cells(Rows.Count, "A")).Clear
End With

Note the . in front of Cells

John Green



"Ade" wrote in message
...
I use the following code to delete cells from the Active Worksheet,

Range("A2", Cells(Rows.Count, "A")).Clear

this works fine but when I try to delete cells from a different sheet in
my
Workbook I get 'Application-defined or Object-defined Error'.
The code which gives this error is,

Worksheets("NotInStock").Range("A2", Cells(Rows.Count, "A")).Clear

any suggestions as to what is wrong with the code?
Thanks.



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
How can I have formatting options like merge cells ,Bold,active for the unlocked cells of the protected worksheet.Is it possible in excel? divya Excel Programming 2 July 20th 06 02:04 PM
how to scroll through active cells instead of entire worksheet mark smith Excel Discussion (Misc queries) 2 March 13th 06 02:29 AM
Unable to delete Active worksheet DS Excel Programming 0 November 22nd 05 03:00 PM
Selecting an Excel tab, Delete Worksheet command is not active missyjes New Users to Excel 1 September 23rd 05 03:16 PM
Marking unlocked cells in active worksheet Zadig Galbaras Excel Discussion (Misc queries) 4 August 13th 05 08:05 PM


All times are GMT +1. The time now is 09:56 PM.

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

About Us

"It's about Microsoft Excel"