?
Solved

Delete rows based on condition

Posted on 2013-06-07
1
Medium Priority
?
227 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
[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
1 Comment
 
LVL 6

Accepted Solution

by:
Michael earned 2000 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
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…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

777 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