ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Catching errors (https://www.excelbanter.com/excel-programming/357911-catching-errors.html)

cbh35711[_10_]

Catching errors
 

So i've filled a column with "=G2*VLOOKUP(D2,Units,2,FALSE)"
Sometimes that's going to fail and the value of the cell will be
#VALUE!.
So then i've got a loop to go through and clear any 0s. However, the
problem occurs when it hits one of the cells that didn't calcuate
right. I want to clear that cell's value, but i wasn't sure how to
catch it.

Do While Not IsEmpty(ActiveCell.Offset(0))

If ActiveCell.Value = 0 Then
ActiveCell.Value = ""
Else: ActiveCell.Value = 1
End If

ActiveCell.Offset(1).Select
Loop


Thanks,

Chris


--
cbh35711
------------------------------------------------------------------------
cbh35711's Profile: http://www.excelforum.com/member.php...o&userid=30276
View this thread: http://www.excelforum.com/showthread...hreadid=529383



All times are GMT +1. The time now is 11:17 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com