Avatar of rawilken
rawilken
Flag for United States of America asked on

Delete Rows in Excel

I have an accounting worksheet where the names of the account are populated using a lookup to a master data set. This lookup leaves the value 0 (zero) for any account number that does not exist in the master data set. So now I want code that will delete all rows where the value in the row for column A is 0 (zero).
Microsoft Excel

Avatar of undefined
Last Comment
Saqib Husain

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Yagya Shree

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
nutsch

Assuming your data starts in cell A1, and your column A is formatted as General, you can use the following autofilter code:

with Cells(1,1).currentregion
.autofilter
.autofilter field:=1, criteria1:="0"
.offset(1).resize(.rows.count-1).specialcells(xlcelltypevisible).entirerow.delete
.autofilter
end with

Open in new window

Saqib Husain

If you want to do this again and again then the above code would be just fine.

If you need this only once then it would be more convenient to apply Data > Filter

and then filter out the zero values and delete them.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck