JeffGrant
Well-known Member
- Joined
- Apr 7, 2021
- Messages
- 558
- Office Version
- 365
- Platform
- Windows
Hi All,
I am using the Index/Match pair in a VBA module. Which I have done many times before. All good.
However, this is first time that I am using the date as a matching variable, and I keep getting it wrong.
I am getting Error 13, data type mis match.
I have got:
1. The FormDate variable declared as Date
2. The Lookup Cell value, the Lookup date, and the Lookup return range are both coming back as Data Type 1, so I am assuming that is correct
3. The format of both the look up value and the return range are in the format of dd-mm-yyyy
I know this line of code works, because when I change it to return other string variables it works great. So it has to do with the date componant
Any ideas and direction is most appreciated because I cant see what I am missing.
I am using the Index/Match pair in a VBA module. Which I have done many times before. All good.
However, this is first time that I am using the date as a matching variable, and I keep getting it wrong.
I am getting Error 13, data type mis match.
I have got:
1. The FormDate variable declared as Date
2. The Lookup Cell value, the Lookup date, and the Lookup return range are both coming back as Data Type 1, so I am assuming that is correct
3. The format of both the look up value and the return range are in the format of dd-mm-yyyy
I know this line of code works, because when I change it to return other string variables it works great. So it has to do with the date componant
Any ideas and direction is most appreciated because I cant see what I am missing.
VBA Code:
Sub IndexMatchCondition()
Dim FormDate As Date
Dim FormTrack as String
Dim RowNum As Integer
On Error Resume Next
For RowNum = 2 To 523
FormDate = Sheet32.Range("A" & RowNum).Value
If Sheet32.Range("B" & RowNum) = "" Then ' Check if FormTrack is blank
GoTo Skip
Else
Sheet32.Range("Z" & RowNum).Value = Application.WorksheetFunction.Index(Sheet8.Range("AX2:AX5000").Value, Application.WorksheetFunction.Match(FormDate, Sheet8.Range("AQ2:AQ5000").Value, 0))
End If
Skip:
Next RowNum
End Sub