Hi All
I got this code from browsing around the web looking for an answer.....
Private Sub CommandButton2_Click()
Dim rng As Range, cell As Range, fmla As String
If TypeName(Selection) <> "Range" Then
MsgBox "Select one or more worksheet cells."
Exit Sub
End If
On Error Resume Next
If Selection.Cells.Count = 1 Then
If Selection = CVErr(x1ErrNA) Then
fmla = Right(Selection.Formula, Len(Selection.Formula) - 1)
Selection.Formula = "=if(isna(" & fmla & "), """"," & fmla & ")"
End If
GoTo e
End If
Set rng = Selection.SpecialCells(x1celltypeformulas, 16)
If rng Is Nothing Then GoTo e
For Each cell In rng
If cell = CVErr(x1ErrNA) Then
fmla = Right(cell.Formula, Len(cell.Formula) - 1)
cell.Formula = "=if(isna(" & fmla & "), """"," & fmla & ")"
End If
Next
e:
On Error GoTo 0
End Sub
What i want is for the code to remove any #N/A cells in my sheet, i have used a index and match formula to look up values for me, and it returns a lot of #N/As but because this sheet can change at any time i dont want to delete out the #N/As i want the formula to stay in the cells, but cant build in an isna or iserror formula with the index and match formula.
Basically i want this code to turn any #N/As in the worksheet to 0 or - but only by clicking the command button?
Would anyone know how this can be done?
Dan
Bookmarks