See if this meets your need.
It will ask for the number of the target column in which to clear the cells. Then it will prompt for column number of the sources cells in which to check for "NaN".
Applicable cells in the first given columns will be cleared.
The code will automatically offset to the left or right of the source columns (cells to check for "NaN"., so entering the first column number is critical.
Sub Delete_X()
Dim c As Range
Dim iCol_1 As Integer, icol_2 As Integer, iVal As Integer
Dim lRow As Long
iCol_1 = Application.InputBox("Enter the column number of the target cells to clear")
icol_2 = Application.InputBox("Enter the column number of the source cells to check")
iVal = iCol_1 - icol_2
lRow = ActiveSheet.Cells(Rows.Count, icol_2).End(xlUp).Row
Application.ScreenUpdating = False
On Error Resume Next
Range(Cells(1, icol_2), Cells(lRow, icol_2)).Select
For Each c In Range(Cells(1, icol_2), Cells(lRow, icol_2))
If c.Value = "NaN" Then
c.Offset(0, iVal).ClearContents
End If
Next c
End Sub
Note: try this on a COPY of your worksheet first as VBA actions cannot be undone.
Bookmarks