Hi
I need someone's help I have the below function that allows me to perform a vlookup in reverse which is great however, when I try to use a data on a different worksheet or workbook I am finding it hard to reference the workbook name or worksheet name as it will always give me the range only
any ideas on how I can get the name from the selected range
I need someone's help I have the below function that allows me to perform a vlookup in reverse which is great however, when I try to use a data on a different worksheet or workbook I am finding it hard to reference the workbook name or worksheet name as it will always give me the range only
any ideas on how I can get the name from the selected range
Code:
Function RVlookup(a As Variant, b As Range, c As Variant)
My_Lookup_Value = a
My_Lookup_Range = b.Address
Offsetcol = c
Debug.Print My_Lookup_Range
strt_col = Range(My_Lookup_Range).Columns.Column
end_col = Range(My_Lookup_Range).Columns.Count + (Range(My_Lookup_Range).Columns.Column - 1)
strt_row = Range(My_Lookup_Range).Rows.Row
end_row = Range(My_Lookup_Range).Rows.Count + (Range(My_Lookup_Range).Rows.Row - 1)
MatchAddress = Cells(strt_row, end_col).Address & ":" & Cells(end_row, end_col).Address
Debug.Print MatchAddress
my_match = Application.Match(My_Lookup_Value, Range(MatchAddress), 0)
val1 = end_col - strt_col + 1 - Offsetcol + 1
log3 = Application.Index(Range(My_Lookup_Range), my_match, val1)
Debug.Print log3
RVlookup = log3
If Offsetcol > end_col Then RVlookup = CVErr(xlErrRef)
End Function