search for cell and clear contents

M

Mike

I am working with a macro and I am in the final stages. I need to clean up
the excel file by deleting all the rows/columns not needed. What I am looking
for is a formula I can add to my macro that searches column A for the first
cell that contains 8 blank spaces " ", when it finds this cell, I
would like the formula to delete that entire row and everything beneath this
row. Something like:
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents
 
C

CoRrRan

Mike said:
I am working with a macro and I am in the final stages. I need to clean up
the excel file by deleting all the rows/columns not needed. What I am looking
for is a formula I can add to my macro that searches column A for the first
cell that contains 8 blank spaces " ", when it finds this cell, I
would like the formula to delete that entire row and everything beneath this
row. Something like:
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents

Try this:

Range("A:A").Find(What:=" ", LookIn:=xlValues).Activate
ActiveCell.Resize(ActiveCell.End(xlDown)).EntireRow.Delete

HTH, CoRrRan
 

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