Clear Doesnt Work

E

ExcelMonkey

I have a named cell in B2. I want to clear all the data starting for
C2 onward down the columns. The following works if my cursor is on th
worksheet of the named cell.

Range("NamedCell").Offset(0, 1).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.ClearContents

How can I mod this so that I do not have to be on the sheet itself?

Thank-yo
 
C

Chip Pearson

Try the following:

With Range("NamedCell")
Range(.Offset(0, 1), .Offset(0, 1).End(xlToRight)).Clear
End With


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
B

Bob Phillips

With Worksheets("Sheet1")
.Range(.Range("NamedCell").Offset(0, 1),
..Range("NamedCell").Offset(0, 1).End(xlToRight)).ClearContents
End With

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 

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

Top