Option Explicit
Public Function MultVlookup( _
FindThis As Variant, _
LookIn As Range, _
SheetRange As String, _
OffsetColumn As Integer, _
Optional ReturnAddress As Boolean = False) _
As Variant
Dim Sheet As Worksheet
Dim strFirstSheet As String
Dim strLastSheet As String
Dim SheetArray() As String
Dim blnFirstSheet As Boolean
Dim rngFind As Range
Dim blnFound As Boolean
Dim intSheets As Integer
Dim n As Integer
'make function recalculate with all changes in data
'else it won't respond to changes in cells on the other worksheets
Application.Volatile
'make search range one column
If LookIn.Columns.Count > 1 Then
Set LookIn = LookIn.Resize(LookIn.Rows.Count, 1)
End If
'size array to hold all worksheet names
ReDim SheetArray(ActiveWorkbook.Worksheets.Count)
'get the two worksheet names
strFirstSheet = Left(SheetRange, InStr(1, SheetRange, ":") - 1)
strLastSheet = Right(SheetRange, _
Len(SheetRange) - InStr(1, SheetRange, ":"))
'put worksheet names in the range 'Sheet Range' into an array
blnFirstSheet = False
n = 0
For Each Sheet In ActiveWorkbook.Worksheets()
If Sheet.Name = strFirstSheet Then
blnFirstSheet = True
End If
If blnFirstSheet = True Then
SheetArray(n) = Sheet.Name
n = n + 1
End If
If Sheet.Name = strLastSheet Then
blnFirstSheet = False
End If
Next Sheet
'save number of sheets
intSheets = n
'search range on each worksheet in array
blnFound = False
For n = 0 To intSheets - 1
With Worksheets(SheetArray(n)).Range(LookIn.Address)
Set rngFind = .Find(FindThis, LookIn:=xlValues, _
MatchCase:=False, LookAt:=xlWhole)
End With
If Not rngFind Is Nothing Then
'match found
blnFound = True
End If
If blnFound = True Then Exit For
Next n
'return value
If blnFound = True Then
If ReturnAddress = False Then
'just return the value
MultVlookup = rngFind.Offset(0, OffsetColumn - 1)
Else
'return the address
MultVlookup = SheetArray(n) & "!" & _
rngFind.Offset(0, OffsetColumn - 1).Address
End If
Else
MultVlookup = CVErr(xlErrNA)
End If
End Function