Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Excel Delete Rows

Posted on 2011-09-28
4
Medium Priority
?
167 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 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

722 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