tiredofit
Well-known Member
- Joined
- Apr 11, 2013
- Messages
- 1,924
- Office Version
- 365
- 2019
- Platform
- Windows
Normally I would use On Error but I want to find out why this doesn't work:
In column A, put some values in cell A1 to A6, ensuring at least one value is zero.
When a value of 0 is encountered, I expected the IfError to return 0 but instead it shows an error message.
What is wrong?
Thanks
In column A, put some values in cell A1 to A6, ensuring at least one value is zero.
Code:
Dim MyArray() As Variant
MyArray() = Cells(1, 1).CurrentRegion.Value
Dim i, j
For i = 1 to 6
j = Application.WorksheetFunction.IfError(1 / MyArray(i,1), 0)
Next i
When a value of 0 is encountered, I expected the IfError to return 0 but instead it shows an error message.
What is wrong?
Thanks
Last edited: