Hi,
I have the following funtion from the guru files page
which actually works great, now I'm trying to call that funtion into a new code like this
But I'm getting the error argument not optional, when I look the sintax it shows that the first one has to be the macro (I assumed here it was the funtion name?) or I'm using wrongly the "Application.Run" as I don't know any other, I'm needing assistance to help me with a new approach here.
Thanks in advance.
I have the following funtion from the guru files page
Code:
Function VLOOKNEW(lookup_value, table_array As Range, _
col_index_num As Integer, CloseMatch As Boolean)
' Allows for col_index_num to be negative
' that matches the lookup value.
Dim nRow As Long
Dim nVal As Integer
Dim bFound As Boolean
VLOOKNEW = "Not Found"
' if positive, treat as a regular VLOOKUP
If col_index_num > 0 Then
VLOOKNEW = Application.WorksheetFunction.VLookup(lookup_value, _
table_array, col_index_num, CloseMatch)
Else
' Do a VLOOKUP Left
nRow = Application.WorksheetFunction.Match(lookup_value, _
table_array.Resize(, 1), CloseMatch)
VLOOKNEW = table_array(nRow, 1).Offset(0, col_index_num)
End If
End Function
which actually works great, now I'm trying to call that funtion into a new code like this
Code:
Sub Data()
Dim wks As Worksheet
Set wks = ActiveSheet
ult = wks.Cells(1048576, 1).End(xlUp).Row
For i = 2 To ult
If wks.Cells(i, 1) <> "" Then
wks.Cells(i, 11) = Application.Run(VLOOKNEW, wks.Cells(i, 8), Sheets("ICP Participants").Columns(2), -1, False)
End If
Next i
End Sub
But I'm getting the error argument not optional, when I look the sintax it shows that the first one has to be the macro (I assumed here it was the funtion name?) or I'm using wrongly the "Application.Run" as I don't know any other, I'm needing assistance to help me with a new approach here.
Thanks in advance.