ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro Clear Cell Contents (https://www.excelbanter.com/excel-programming/402272-macro-clear-cell-contents.html)

Frank

Macro Clear Cell Contents
 
I am trying to write this into my current macro where I clear the cells that
don't contain the letters "RO" in the below range.

Range("B4:BQ20").Select

Any help is greatly appreciated. Thank you


Jim Thomlinson

Macro Clear Cell Contents
 
One way...

Sub ClearStuff()
Dim rng As Range

For Each rng In Range("B4:BQ20")
If InStr(UCase(rng.Value), "RO") = 0 Then _
rng.ClearContents
Next rng
End Sub
--
HTH...

Jim Thomlinson


"Frank" wrote:

I am trying to write this into my current macro where I clear the cells that
don't contain the letters "RO" in the below range.

Range("B4:BQ20").Select

Any help is greatly appreciated. Thank you


Frank

Macro Clear Cell Contents
 
Jim, Thank you, it works well.

"Jim Thomlinson" wrote:

One way...

Sub ClearStuff()
Dim rng As Range

For Each rng In Range("B4:BQ20")
If InStr(UCase(rng.Value), "RO") = 0 Then _
rng.ClearContents
Next rng
End Sub
--
HTH...

Jim Thomlinson


"Frank" wrote:

I am trying to write this into my current macro where I clear the cells that
don't contain the letters "RO" in the below range.

Range("B4:BQ20").Select

Any help is greatly appreciated. Thank you



All times are GMT +1. The time now is 07:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com