Table of Contents
VLOOKUP is a popular function in Microsoft Excel that allows users to search for a specific value and retrieve information from a designated table. In VBA (Visual Basic for Applications), it is possible to use the VLOOKUP function from another sheet. This can be done by referencing the sheet name and cell range in the function’s formula. This feature provides flexibility and convenience for VBA users who need to perform data lookup and retrieval tasks across multiple sheets. Furthermore, it allows for smoother automation of data handling processes.
VBA: Use VLOOKUP From Another Sheet
You can use the following basic syntax to perform a VLOOKUP from another sheet using VBA:
Sub Vlookup()
Range("B2").Value = WorksheetFunction.Vlookup(Range("A2"), Sheets("Sheet2").Range("A2:C11"),3,False)
End SubThis particular example looks up the value in cell A2 of the current sheet in the range A2:C11 of the sheet called Sheet2 and finds the corresponding value in the third column of the range and then assigns the result to cell B2 in the current sheet.
Note: The last argument of False specifies that we want an exact match.
The following example shows how to use this syntax in practice.
Example: How to Use VLOOKUP From Another Sheet in VBA
Suppose we have the following dataset in a sheet called Sheet2 in an Excel workbook that contains information about various basketball players:

Now suppose we switch to the sheet called Sheet1 and would like to look up the team name “Kings” in the dataset from Sheet2 and return the corresponding value in the assists column in Sheet1.

We can create the following macro to do so:
Sub Vlookup()
Range("B2").Value = WorksheetFunction.Vlookup(Range("A2"), Sheets("Sheet2").Range("A2:C11"),3,False)
End SubWhen we run this macro, we receive the following output:

The macro correctly returns a value of 3 assists for the Kings.
If we change the name of the team in cell A2 and then run the macro again, it will correctly find the assists value for the new team name.
For example, suppose we change the team name to Warriors” and run the macro again:

The macro correctly returns a value of 4 assists for the Warriors.
Note: You can find the complete documentation for the VBA VLookup method .
Cite this article
stats writer (2024). Can VLOOKUP be used from another sheet in VBA?. PSYCHOLOGICAL SCALES. Retrieved from https://scales.arabpsychology.com/stats/can-vlookup-be-used-from-another-sheet-in-vba/
stats writer. "Can VLOOKUP be used from another sheet in VBA?." PSYCHOLOGICAL SCALES, 24 Jun. 2024, https://scales.arabpsychology.com/stats/can-vlookup-be-used-from-another-sheet-in-vba/.
stats writer. "Can VLOOKUP be used from another sheet in VBA?." PSYCHOLOGICAL SCALES, 2024. https://scales.arabpsychology.com/stats/can-vlookup-be-used-from-another-sheet-in-vba/.
stats writer (2024) 'Can VLOOKUP be used from another sheet in VBA?', PSYCHOLOGICAL SCALES. Available at: https://scales.arabpsychology.com/stats/can-vlookup-be-used-from-another-sheet-in-vba/.
[1] stats writer, "Can VLOOKUP be used from another sheet in VBA?," PSYCHOLOGICAL SCALES, vol. X, no. Y, ص Z-Z, June, 2024.
stats writer. Can VLOOKUP be used from another sheet in VBA?. PSYCHOLOGICAL SCALES. 2024;vol(issue):pages.
