Solved

Delete rows based on condition

Posted on 2013-06-07
1
179 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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

A2 = A1 That kind of cell reference is relative.  If you copy it from A2 to B2, then B2 will get this: B2 = B1 That's all fine and good, but if you then insert a new row above row 2, you'll find: A3 = A1 B3 = B1 This is intentional. …
Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
Viewers will learn the basics of slicers and timelines for both PivotTables and standard Excel tables in Excel 2013.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

771 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

9 Experts available now in Live!

Get 1:1 Help Now