VBA Code - Delete Columns

ChrisFoster

Active Member
Joined
Jun 21, 2019
Messages
256
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I have some coding that I am using which neatens up a report that I pull from my work's system.

What I want is some VBA code that auto deletes any rows where "Pending Failure" is displayed in column E. All data in Column E though is formulas in each cell (apart from the header).

Please can someone help?

Cheers

Chris
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
How about
Code:
Sub ChrisFoster()
   With ActiveSheet
      .Range("A1:E1").AutoFilter 5, "Pending Failure"
      .AutoFilter.Range.Offset(1).EntireRow.Delete
      .AutoFilterMode = False
   End With
End Sub
 
Upvote 0
How about
Code:
Sub ChrisFoster()
   With ActiveSheet
      .Range("A1:E1").AutoFilter 5, "Pending Failure"
      .AutoFilter.Range.Offset(1).EntireRow.Delete
      .AutoFilterMode = False
   End With
End Sub

That works perfectly, thanks so much.
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0
Hi,

You may be able to help me advance further on my code. Do you know how I'd delete all rows apart from row 1, where column B does not contain the word "Arrears"? SO basically I just want to keep the rows where column B contains the word "Arrears".

Cheers

Chris
 
Upvote 0
The same code, but with this mod
Code:
.Range("A1:E1").AutoFilter 2, "<>*arrears*"
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,254
Members
452,623
Latest member
Techenthusiast

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top