ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   search for cell and clear contents (https://www.excelbanter.com/excel-programming/390902-search-cell-clear-contents.html)

Mike

search for cell and clear contents
 
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

CoRrRan

search for cell and clear contents
 
Mike wrote:
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)).EntireRo w.Delete

HTH, CoRrRan


All times are GMT +1. The time now is 07:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com