If Cell String meets criteria, then clearcontents from array on same row

dversloot1

Board Regular
Joined
Apr 3, 2013
Messages
113
Hello,

I'm attempting to clear the contents from a range of cells on rows where a cell string may equal R, X, XX, Y, Z, ZX, #N/A.
The macro runs fine until it gets to a cell that contains #N/A. Any idea how to get this to work?

Sub Recalculate()


Dim r As Integer
r = ActiveSheet.UsedRange.Rows.Count


Application.ScreenUpdating = False


For Row = 13 To r
If _
Range("M" & Row) = "R" Or _
Range("M" & Row) = "X" Or _
Range("M" & Row) = "XX" Or _
Range("M" & Row) = "Y" Or _
Range("M" & Row) = "Z" Or _
Range("M" & Row) = "ZX" OR _
Range("M" & Row) = "#N/A" _
Then Range("O" & Row & ":Y" & Row).ClearContents Else
Next Row


Application.ScreenUpdating = True


End Sub
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Does the following work:
Code:
:
:
VarType(Range("M" & Row)) = vbError
 
Upvote 0

Forum statistics

Threads
1,216,057
Messages
6,128,523
Members
449,456
Latest member
SammMcCandless

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top