Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How can I have formatting options like merge cells ,Bold,active for the unlocked cells of the protected worksheet.Is it possible in excel? | Excel Programming | |||
how to scroll through active cells instead of entire worksheet | Excel Discussion (Misc queries) | |||
Unable to delete Active worksheet | Excel Programming | |||
Selecting an Excel tab, Delete Worksheet command is not active | New Users to Excel | |||
Marking unlocked cells in active worksheet | Excel Discussion (Misc queries) |