Solved

Delete rows based on condition

Posted on 2013-06-07
1
193 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Find word and 6 digit number 22 98
Generating a graph via Excel 3 27
Auto Adjust Percent rate 5 30
remove upper case characters in excel 4 19
Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

896 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now