Solved

Excel Delete Rows

Posted on 2011-09-28
4
130 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Sparklines have been introduced with Excel 2010 and are a useful tool for creating small in-cell charts, used for example in dashboards. Excel 2010 offers three different types of Sparklines: Line, Column and Win/Loss. What it does not offer is a…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

747 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

13 Experts available now in Live!

Get 1:1 Help Now