Remote clearance

F

Francis Hookham

This works:
Sheets("Schedule").Select
Range(Cells(25, 1), Cells(LastUsedRow, LastUsedCol)).ClearContents

this doesn't:
Sheets("Schedule").Range(Cells(25, 1), Cells(LastUsedRow,
LastUsedCol)).ClearContents

I should like to work in another sheet without actually selecting it.

I'm sure I am just missing something simple.............!

Francis Hookham
 
D

Dave Peterson

Unqualified ranges refer to the activesheet (when the code is in a general
module).

Try
Sheets("Schedule").Range(Sheets("Schedule").Cells(25, 1), _
Sheets("Schedule").Cells(LastUsedRow, LastUsedCol)).ClearContents

or less typing

with Sheets("Schedule")
.range(.cells(25,1),.cells(lastusedrow,lastusedcolumn)).clearcontents
end with

The dots in front of .range, .cells means that they belong to the object in the
previous with statement.
 
F

Francis Hookham

Very useful - wonderful to learn something new every day - what a life!

Francis Hookham
 
Top