Remote clearance

  • Thread starter Thread starter Francis Hookham
  • Start date Start date
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
 
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.
 
Very useful - wonderful to learn something new every day - what a life!

Francis Hookham
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top