Hello everyone,
Can I use Application.Match to find the first "Empty" element of an array ? Please refer to the below code, looking at the Locals window, once the array is created, all elements of the array have "Empty" value so the first debug.print give Error 2042 as I was looking for the first "Empty" element of the array. Is this possible to do with Application.Match ? Is there a different (non-loop) method to find the first "Empty" element of the array ?
The second question I have is this is a zero-based array & when looking at the results of the 2nd debug.print, it gives 1 while 1 refers to the 2nd element Arr(1) = "two". Does Application.Match works correct with 2d arrays ?
Just trying to understand the logic
Can I use Application.Match to find the first "Empty" element of an array ? Please refer to the below code, looking at the Locals window, once the array is created, all elements of the array have "Empty" value so the first debug.print give Error 2042 as I was looking for the first "Empty" element of the array. Is this possible to do with Application.Match ? Is there a different (non-loop) method to find the first "Empty" element of the array ?
The second question I have is this is a zero-based array & when looking at the results of the 2nd debug.print, it gives 1 while 1 refers to the 2nd element Arr(1) = "two". Does Application.Match works correct with 2d arrays ?
Just trying to understand the logic
VBA Code:
Sub test()
Dim Arr(0 To 4)
Arr(0) = "one"
Arr(1) = "two"
Arr(4) = "five"
Debug.Print Application.Match(Empty, Arr, 0)
Debug.Print Application.Match("one", Arr, 0),
Debug.Print Arr(Application.Match("one", Arr, 0))
End Sub