# vba find and clear contents



## bcselect (Dec 27, 2022)

I've asked something similar before but this time I can't get it to work.  
VBA if value=M in column A, clear the contents of cell to right (column B). Else skip and go to next row.​ 

M1​1​M1​1​M1​1​M1​1​M1​1​1​1​1​1​1​1​1​1​1​1​


----------



## Micron (Dec 27, 2022)

maybe

```
Sub bcSelect()
Dim Lrow As Long
Dim i As Integer

Lrow = Cells(Rows.count, "A").End(xlUp).Row
For i = 2 To Lrow '2 assumes row 1 is header row, so start in row 2
     If UCase(Range("A" & i)) = "M" Then Range("A" & i).Offset(0, 1).Clear
Next

End Sub
```


----------



## bcselect (Dec 27, 2022)

Micron said:


> maybe
> 
> ```
> Sub bcSelect()
> ...


Absolutely perfect!  Thanks.


----------



## Micron (Dec 27, 2022)

Great! Thanks for the acknowledgement.


----------

