Try the next way, please:
Sub lastOccurrenceMatch()
Dim a As Variant, index As Integer
a = Array(1, 2, 3, 4, 1, 2, 3, 4, 5)
index = Application.Match(CStr(4), Split(StrReverse(Join(a, "|")), "|"), 0) '2
Debug.Print index, UBound(a) + 1 - index + 1
End Sub
Or a version not raising an error in case of no match:
Sub lastOccurrenceMatchBetter()
Dim a As Variant, index As Variant
a = Array(1, 2, 3, 4, 1, 2, 3, 4, 5)
index = Application.Match(CStr(4), Split(StrReverse(Join(a, "|")), "|"), 0) '2
If Not IsError(index) Then
Debug.Print index, UBound(a) + 1 - index + 1
Else
Debug.Print "No any match..."
End If
End Sub
Edited:
The next version reverses the array as it is (without join/split sequence). Just using Index. Just for the sake of playing with arrays:
Sub testMatchReverseArray()
Dim a As Variant, index As Integer, cnt As Long, col As String, arrRev()
a = Array(1, 2, 3, 4, 1, 12, 3, 4, 15)
cnt = UBound(a) + 1
col = Split(cells(1, cnt).Address, "$")(1)
arrRev = Evaluate(cnt & "+1-column(A:" & col & ")") 'build the reversed columns array
a = Application.index(Application.Transpose(a), arrRev, 0)
Debug.Print Join(a, "|") 'just to visually see the reversed array...
index = Application.match(4, a, 0)
Debug.Print index, UBound(a) + 1 - index + 1
End Sub
Second Edit:
The next solution matches the initial array with one loaded with only element to be searched. Then reverse it (using StrReverse) and search the matching positions ("1"):
Sub MatchLastOccurrence()
Dim a(), arr(), srcVar, arrMtch(), index As Integer
a = Array(1, 2, 3, 4, 1, 12, 3, 4, 15)
srcVar = 4 'the array element to identify its last position
arr = Array(srcVar)
arrMtch = Application.IfError(Application.match(a, arr, 0), 0)
Debug.Print Join(arrMtch, "|") '1 for matching positions, zero for not matching ones
index = Application.match("1", Split(StrReverse(Join(arrMtch, "|")), "|"), 0) '2
Debug.Print index, UBound(a) + 1 - index + 1
End Sub