Guest User

Untitled

a guest
May 25th, 2017
499
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Public Function INDEXMATCH(LookupValue, LookupColumn As Range, ReturnColumn As Range)
  2.     On Error GoTo ErrorHandler
  3.    
  4.     INDEXMATCH = WorksheetFunction.Index(ReturnColumn, WorksheetFunction.Match(LookupValue, LookupColumn, 0))
  5.  
  6. Done:
  7.     Exit Function
  8. ErrorHandler:
  9.     If Err.Number = 1004 Then
  10.         INDEXMATCH = "N/A"
  11.     End If
  12. End Function
  13.  
  14. Public Function INDEXMATCHMATCH(VertLookupValue, HorizLookupValue, LookupMatrix As Range)
  15.     On Error GoTo ErrorHandler
  16.    
  17.     LeftColumn = LookupMatrix.Columns(1)
  18.     TopRow = LookupMatrix.Rows(1)
  19.    
  20.     INDEXMATCHMATCH = WorksheetFunction.Index(LookupMatrix, WorksheetFunction.Match(VertLookupValue, LeftColumn, 0), WorksheetFunction.Match(HorizLookupValue, TopRow, 0))
  21.  
  22. Done:
  23.     Exit Function
  24. ErrorHandler:
  25.     If Err.Number = 1004 Then
  26.         INDEXMATCHMATCH = "N/A"
  27.     End If
  28. End Function
Advertisement
Add Comment
Please, Sign In to add comment