Ashe
New Member
- Joined
- Dec 2, 2023
- Messages
- 9
- Office Version
- 2021
- Platform
- Windows
I have data in column B that has multiple codes in it. A majority of the codes aren't needed for what I'm calculating, and instead of writing all the codes what I want deleted, is there a way to code what I codes DON'T want to delete and delete all other rows of data?
Here are the codes I want to KEEP:
LN_OTHER/MISC
LN_LEARNING_STAFF
LN_PITCLASSRM_TRAING
LN_TDRCLASSRM_TRAING
Here's what I currently have for my code, which deletes specified codes:
Any help is greatly appreciated! Thanks in advance
Here are the codes I want to KEEP:
LN_OTHER/MISC
LN_LEARNING_STAFF
LN_PITCLASSRM_TRAING
LN_TDRCLASSRM_TRAING
Here's what I currently have for my code, which deletes specified codes:
I could use an autofilter, but I'd prefer to omit the data altogether as I may need to further manipulate the data as I develop this document.'Delete any irrelevant data
Dim LastRow As Long, n As Long
LastRow = Cells.SpecialCells(xlCellTypeLastCell).Row
For n = LastRow To 1 Step -1
If Range("B" & n).Value = "Irrelevant_Code_1" Or _
Range("B" & n).Value = "Irrelevant_Code_2" Or _
Range("B" & n).Value = "Irrelevant_Code_3" Or _
(Etc etc for a lot of rows...) Then
Rows ( n ) .Delete
End If
Next
Any help is greatly appreciated! Thanks in advance