MojoJojo2023
New Member
- Joined
- Aug 7, 2023
- Messages
- 9
- Office Version
- 365
- 2021
- 2019
- Platform
- Windows
Hi all!
I am attempting to build a custom function to pass values to an array and return a value based on whether criteria matches the passed values. I am not new to VBA, but am trying to learn utilize arrays to process more in memory. Any feedback on the issue with the below would be appreciated. Thanks in advance! :
I am attempting to build a custom function to pass values to an array and return a value based on whether criteria matches the passed values. I am not new to VBA, but am trying to learn utilize arrays to process more in memory. Any feedback on the issue with the below would be appreciated. Thanks in advance! :
VBA Code:
Function NP(term As Integer, dte As Date, rng As Range) As Double
Dim tmparray As Variant
Dim i As Long, j As Long
tmparray = rng
For i = LBound(tmparray, 1) To UBound(tmparray, 1)
For j = LBound(tmparray, 1) To UBound(tmparray, 15)
If tmparray(i, 1).Value = dte And tmparray(i, 3).Value = "Yes" And tmparray(i, 7).Value = term Then
NP = tmparray(i, 12)
End If
Next j
Next i
End Function