Solved

Excel Delete Rows

Posted on 2011-09-28
4
154 Views
Last Modified: 2012-05-12
Hello Experts,

Can someone please help write a formula / macro that will delete all the rows with AP3 in column A?

Cheers
28-09-11-ALL.xlsx
0
Comment
Question by:cpatte7372
  • 3
4 Comments
 
LVL 24

Accepted Solution

by:
StephenJR earned 500 total points
ID: 36720551
You could just sort and delete manually, or with code, if you add a header row (anything will do):
Sub x()

Dim rData As Range

Application.ScreenUpdating = False

With ActiveSheet
    .AutoFilterMode = False
    .Range("A1").AutoFilter Field:=1, Criteria1:="AP3"
    With .AutoFilter.Range
        On Error Resume Next
        Set rData = .Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlCellTypeVisible)
        On Error GoTo 0
        If Not rData Is Nothing Then
            rData.EntireRow.Delete
        End If
    End With
    .AutoFilterMode = False
End With

Application.ScreenUpdating = True

End Sub

Open in new window

0
 

Author Comment

by:cpatte7372
ID: 36720579
Hello Stephen mate,

Unfortunately, I couldn't sort and delete manually because of the order and timing are crucial. You're formula appears to have done the trick though. Just checking it out thoroughly now. Will let you know for sure in 15mins.

Cheers
0
 

Author Comment

by:cpatte7372
ID: 36720586
Smashing.

Cheers mate.
0
 

Author Closing Comment

by:cpatte7372
ID: 36720587
Brilliant
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
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 demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

839 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