I am trying to do a lookup function but it does not compile error occurs at this line:
Could someone please help?
Function look(a As String) As Integer 'a is string looking up in cell
Dim myarr As String
Dim index As Long, row_index As Long, i As Integer
row_index = 2
Dim last_row As Integer
last_row = lookup.Range("d2").End(xlUp).Row
MsgBox last_row
ReDim myarr(last_row) 'redefine dimensions of array since have last row
For i = 1 To last_row
myarr(index) = lookup.Cells(row_index, 4).Value 'col D string values stored in array
If a = myarr(index) Then
look = lookup.Cells(row_index, 3).Value
MsgBox look
Else
End If
row_index = row_index + 1
index = index + 1
Next
End Function
Bookmarks