Adding another Condition to VBA Code

Russ At Index

Well-known Member
Joined
Sep 23, 2002
Messages
706
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
  2. MacOS
Good afternoon ,

Please see code below ...

I have a small problem whereby i wish to delete other named criteria as well as REP 00 from by worksheet.
Along with REP 00 , I wish to also delete rows that contain ( in column D ) , CON 01 , CON 02 and CRT 99.

I am no great "VBAer" , i'm afraid to say , would someone point me in the right direction please .

Many thanks ,

Russ.

Sub test()
With ActiveSheet
.AutoFilterMode = False
With Range("d1", Range("d" & Rows.Count).End(xlUp))
.AutoFilter 1, "*REP 00*"
On Error Resume Next
.Offset(1).SpecialCells(12).EntireRow.Delete
End With
.AutoFilterMode = False
End With
End Sub
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Are the values REP 00, CON 01 etc on there own in the cell, or part of a larger string?
Also is it just the 4 values, or are there more?
 
Upvote 0
Hi Fluff ,

Hope you are well ,

All there is in the cell in column D is , for example REP 00 , so i need to delete that particular row , along with the other criteria mentioned.

The 4 values are the ones that i need to remove , it will leave : FRA 01 , SHE 01 , PIC 00 , PIC 01 , LIQ 00

Thanks ,

Russ,
 
Upvote 0
Ok, how about
VBA Code:
Sub RussAtIndex()
   Dim Ary As Variant
   
   Ary = Array("Rep 00", "con 01", "con 02", "crt 99")
   With ActiveSheet
      .AutoFilterMode = False
      .Range("A1:D1").AutoFilter 4, Ary, xlFilterValues
      .AutoFilter.Range.Offset(1).EntireRow.Delete
      .AutoFilterMode = False
   End With
End Sub
 
Upvote 0
In the immortal words of Del Boy ..... "He's only cracked it !!"

Thanks Fluff , as ever fantastic help :)

Russ
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,944
Messages
6,122,384
Members
449,080
Latest member
Armadillos

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