Hi All
I am trying to write the vba code for the Match & Index functions. My code results in a Runtime Error 1004: Application defined or object defined error.
My code is:
Private Sub Test()
Dim t As String
Dim TypeTable as Range
Dim AccNo as Range
t = Application.WorksheetFunction.Index(Sheets("ChartOfAccounts").Range("TypeTable"), Application.WorksheetFunction.Match(Left(Sheets("Journal").Range("C27").Value, 6), Sheets("ChartOfAccounts").Range("AccNo"), 0), 1)
End Sub
I have tested the "Left(Sheets("Journal").Range("C27").Value, 6)" and the "Index" portion of the code with no errors. The error occurs on the "Match" portion of the code.
The variables "TypeTable" and "AccNo" are Named Ranges on the "ChartOfAccounts" worksheet.
I would appreciate it if anyone could please tell me what I am doing wrong.
I have subequently changed the code by removing "WorksheetFunction" - see new code below:
Private Sub Test()
Dim t As String
Dim TypeTable as Range
Dim AccNo as Range
t = Application.Index(Sheets("ChartOfAccounts").Range("TypeTable"), Application.Match(Left(Sheets("Journal").Range("C27").Value, 6), Sheets("ChartOfAccounts").Range("AccNo"), 0), 1)
End Sub
This has resolved the Runtime Error 1004, but now I have an Error 13 Type Mismatch error.
Any suggestions will be highly appreciated.
Thank you
Bookmarks