Solved

Delete rows based on condition

Posted on 2013-06-07
1
203 Views
Last Modified: 2013-06-11
I need help please with VBA to delete rows on Sheet19 where Column E = "1".  Thanks in Advance.  I have looked for code but nothing seems to help.
0
Comment
Question by:leezac
1 Comment
 
LVL 6

Accepted Solution

by:
Michael earned 500 total points
ID: 39230701
Hi leezac,
this code should do it. It looks in column E for the last used row and then goes upward and deletes a row whenever cell E of that row is "1".

First, try it on a copy of your workbook, as you can't undo it.

sub DelRows()
Dim Lst     As Long
Dim n       As Long

With Sheets("Sheet19")
Lst = .Range("E" & .Rows.Count).End(xlUp).row
For n = Lst To 2 Step -1
    With .Range("E" & n)
        If .Value = 1 Then
            .EntireRow.Delete
        End If
     End With
Next n
End With
End Sub

Open in new window

0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
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…
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…

786 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