Solved

Excel Delete Rows

Posted on 2011-09-28
4
162 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
[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
  • 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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
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…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

624 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