?
Solved

Delete Rows in Excel

Posted on 2012-12-26
3
Medium Priority
?
180 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 13

Accepted Solution

by:
Yagya Shree earned 400 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

752 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