What VBA Coding can filter out and delete multiple criteria?

Posting in the hope I’m not flame grilled. Bluntly, I’m a novice and though I’m trying my best, Rome wasn’t built in a day and I’m stuck.

I’ve had some help elsewhere and Kudos to the person, they are in a hugely different timezone and I don’t want to bombard them.

I pull a report from Power BI into Excel. Current coding I have now is to delete bottom 3 rows, remove rows with duplicate PO numbers in Column A (1), Filter and remove every entry except “Approved” in Column J (10). This has been tested and works great.

There are still thousands of lines left which need filtering and deleting to leave the data I want, and here is the sticking point…

Column H (8) is where names are input in the original program. When an action has been taken we prefix this with an “R”. Unfortunately each colleague seems to have their own way of doing this and there are multiple entries to try and go through. Combine multiple R prefix methods with many names and filtering / deleting these prefixed entries becomes everyone’s worst nightmare. There are some other prefixes too but the Rs are the absolute bane of our lives. 1000s of lines. We want to remove all prefixed entries from the worksheet.

The most common theme is an “R” followed by a space or a hyphen. The below is a capture of the ones I’ve spotted so far, with Test Text input rather than names here for obvious reasons (Real Data is to reflect where a name we want to retain might start with an R, i.e. Rebecca and the XX or * prefix is another one we filter and delete results for):

R – Test Text
R Test Text
R-Test Text
RTest Text
Real Data
R-
R Test Text
R- Test Text
R_Test Text
XX Test Text
*Test Text

The ones with RTest Text probably will have to be done manually but can all other instances have those rows removed via VBA or are there just too many?

I tried to attempt coding based on some info I was given but it went horribly wrong and deleted everything I wanted and left a few entries that I didn’t want. Please see below:

`Option Explicit
Sub RsRemovalTest()
Dim ws As Worksheet, LRow As Long
Set ws = ActiveSheet
LRow = ws.Cells.Find(“*”, , xlFormulas, , 1, 2).Row

ws.Cells(LRow, 1).Offset(-2).Resize(3).EntireRow.Delete
If ws.AutoFilterMode Then ws.AutoFilter.ShowAllData
With ws.Range("A1").CurrentRegion
    .RemoveDuplicates Columns:=1, Header:=xlYes
    .AutoFilter 10, "<>Approved"
    If .SpecialCells(xlCellTypeVisible).Address <> .Rows(1).Address Then
        .Offset(1).EntireRow.Delete
    End If
    .AutoFilter 8, "R *", 2, "R-*", 3, "XX*"
    If .SpecialCells(xlCellTypeVisible).Address <> .Rows(1).Address Then
        .Offset(1).EntireRow.Delete
    End If
    .AutoFilter
End With

End Sub`

I’d be ever so grateful for help, but if novices aren’t permitted to ask, I understand and thanks to anyone taking the time to read.

Tried to search for info online but I lack the understanding on where I put things and how to rectify the wrong info being deleted.

New contributor

SalsaMoon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật