Solved

Delete Rows in Excel

Posted on 2012-12-26
3
176 Views
Last Modified: 2012-12-27
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).
0
Comment
Question by:rawilken
3 Comments
 
LVL 13

Accepted Solution

by:
Yagya Shree earned 100 total points
ID: 38721426
0
 
LVL 39

Expert Comment

by:nutsch
ID: 38721427
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

0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 38721495
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.
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question