Solved

Excel Delete Rows

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

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…
Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

803 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