Alex Italo
New Member
- Joined
- Nov 19, 2004
- Messages
- 4
Hello,
I use a VBA code to clear rows that have an specific field equal to zero.
Example: If cell D11 = 0 then the contents of all cells in row 11 are deleted.
The code goes like this:
If Sheets("WKST").Range("D11").Value = 0 Then
Sheets("WKST").Range("D1:D20").ClearContents
End If
The problem is that D11 may contain an error (like #DIV!0), since its value is calculated by a formula and the macro stops when the cell has an error accusing "incompatible types".
I can't include another IF function in the cell 'cause there are already too many nested IF's and the formula is so big that I almost used all space available.
I would like to know how to test the contents of a cell using VBA to know if there is an error.
Any help would be appreciated!
I use a VBA code to clear rows that have an specific field equal to zero.
Example: If cell D11 = 0 then the contents of all cells in row 11 are deleted.
The code goes like this:
If Sheets("WKST").Range("D11").Value = 0 Then
Sheets("WKST").Range("D1:D20").ClearContents
End If
The problem is that D11 may contain an error (like #DIV!0), since its value is calculated by a formula and the macro stops when the cell has an error accusing "incompatible types".
I can't include another IF function in the cell 'cause there are already too many nested IF's and the formula is so big that I almost used all space available.
I would like to know how to test the contents of a cell using VBA to know if there is an error.
Any help would be appreciated!