tiredofit
Well-known Member
- Joined
- Apr 11, 2013
- Messages
- 1,924
- Office Version
- 365
- 2019
- Platform
- Windows
I have these formulae in cells:
How can I create this in a VBA array?
For Example:
If only B1 OR D1 is zero, it will error out but how can my array know which one errors?
Thanks
Code:
=IF(ISERROR(A1/B1),0,A1/B1)
=IF(ISERROR(C1/D1),0,C1/D1)
How can I create this in a VBA array?
For Example:
Code:
Dim DataArray() As Variant
DataArray = Cells(1,1).CurrentRegion.Value
Dim MyArray(1 To 10, 1 To 2) As Variant
Dim Counter As Integer
On Error GoTo ErrHandler
For Counter = 1 To 10
MyArray(Counter, 1) = DataArray(Counter, 1) / DataArray(Counter, 2)
MyArray(Counter, 2) = DataArray(Counter, 3) / DataArray(Counter, 4)
Next Counter
Exit Sub
ErrHandler:
MyArray(Counter, 1) = 0
MyArray(Counter, 2) = 0
Resume Next
If only B1 OR D1 is zero, it will error out but how can my array know which one errors?
Thanks
Last edited: