I have written a VBA code for my excel file. In the VBA code, I have to delete cells having formula. My code is working fine if it found at least one cell having formula but if there is no such cell then it shows an error - run time error '1004'.
my code is
Dim n As Integer
n = Sheets("Pay_Slip").Range("B11:AO510").SpecialCells(xlCellTypeFormulas, 23).Count
If n > 0 Then
Sheets("Pay_Slip").Range("B11:AO510").Select
Selection.SpecialCells(xlCellTypeFormulas, 23).Select
Selection.ClearContents
End If
Please help me in finding the error.