Clear contents

G

Guest

Hi! I am trying to clear contents in a range of cells but i fail with the
syntax. I want to clear contents starting at cell D5. I want the clear
contents to end where there is nothing more to the right of cell D5 and then
go down to find the last cell with content. I have tried to do that with the
code below but it is somehow wrong. any help appreciated! thanks alot!

ActiveSheet.Range(Cells(5, 4), Cells(Range("C5").End(xlDown).Row,
Range("d5").End(xlToRight))).ClearContents
 
G

Guest

Forgot .Column...
ActiveSheet.Range(Cells(5, 4), Cells(Range("C5").End(xlDown).Row, _
Range("d5").End(xlToRight).Column)).ClearContents
 
G

Guest

Oh, and did you mean "D5" for the row?
ActiveSheet.Range(Cells(5, 4), Cells(Range("D5").End(xlDown).Row, _
Range("d5").End(xlToRight).Column)).ClearContents

Alternatively, if there is nothing connected above and to the left of "D5"
you can use the CurrentRegion Property:
Range("D5").CurrentRegion.ClearContents
 
W

WhytheQ

I think the last bit is missing ".column"
So Range("d5").End(xlToRight) needs .column tagged on the end

Regards
J
 

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