NachoBoacity
New Member
- Joined
- Oct 18, 2022
- Messages
- 2
- Office Version
- 2019
- Platform
- Windows
I have column "D" with a lot of values, however I would only like to keep the cells within that column which contain values "132" or "133" or "54". How could I clear content if value is not stated in the array?
This is the closest code I found... It is broken as I tried to adjust it to my scenario, so probably not even worth looking at!
Thank you.
This is the closest code I found... It is broken as I tried to adjust it to my scenario, so probably not even worth looking at!
Thank you.
VBA Code:
Sub MyClearMacro()
Dim lr As Long
Dim r As Long
Application.ScreenUpdating = False
' Find last row in column P with data
lr = Cells(Rows.Count, "D").End(xlUp).Row
' Loop through all rows
For r = 2 To lr
If Cells(r, "D") <> "133" Or "132" OR "Etc Etc" Then Range(Cells(r, "D"), Cells(r, "D")).ClearContents
Next r
Application.ScreenUpdating = True
End Sub
Last edited by a moderator: