Empty a cell if the values equal to "IN" , "MC" or "PP"

Y

YHT

Hi all,

Could someone tell me how to write a script to empty a cell if the current
cell value is equal to "IN", "MC" or "PP"? I need to search from first cell
in Column B till the last cell in the same column.

Thanks.
 
G

Gary Keramidas

here is one way, just change the sheet reference:

Option Explicit

Sub empty_some_cells()
Dim ws As Worksheet
Dim lastrow As Long
Dim cell As Range
Dim rng As Range
Application.ScreenUpdating = False
Set ws = Worksheets("Sheet1")
lastrow = ws.Cells(Rows.Count, "B").End(xlUp).Row
Set rng = ws.Range("B1:B" & lastrow)
For Each cell In rng
Select Case cell.Value
Case "IN", "MC", "PP"
cell.Value = ""
End Select
Next
Application.ScreenUpdating = True
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top