clearing cells

  • Thread starter Thread starter MJKelly
  • Start date Start date
M

MJKelly

Hi,

Can you tell me what is wrong with this code?


wksDump.Range(Cells(2, 1), Cells(1000, 256)).ClearContents

If I put in wksdump.cells.clearcontents it clears the whole sheet. I
want to keep the data in row 1.

hope you can help.

Thanks,
Matt
 
Those Cells() don't refer to wksDump. If the code is in a general module, they
refer to the active sheet.

If the code is behind a worksheet, they refer to the sheet with the code:

Either:

wksDump.Range(wksdump.Cells(2, 1), wksdump.Cells(1000, 256)).ClearContents

or
with wksDump
.Range(.Cells(2, 1), .Cells(1000, 256)).ClearContents
end with

(notice the dots in front of .range() and both .cells().)

or even...

wksDump.Cells(2, 1).resize(999,256).clearcontents
 
With Sheets(wksDump)
..Range(Cells(2, 1), Cells(1000, 256)).ClearContents
End With

I'm assuming that wksDump is the name of a sheet...
 

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