Safal Kamaruddin
Safal Kamaruddin

Reputation: 11

Performing multiple vlookup operation in VBA

I have a logical doubt. Is it possible to return a value to a cell by performing Vlookup operation in 3 sheets, i.e the value to be returned might be in one of the three sheets. If so how can I approach this? I am trying to create a macro using VBA.

Upvotes: 1

Views: 71

Answers (1)

Pierre Chevallier
Pierre Chevallier

Reputation: 754

if there are no real differences between the worksheets you can use formulas instead of VBA using =IFERROR() and =VLOOKUP()

An example would be:

=IFERROR(VLOOKUP(valueToLookFor,sheet1Range,columnNumber,FALSE),IFERROR(VLOOKUP(valueToLookFor,sheet2Range,columnNumber,FALSE),VLOOKUP(valueToLookFor,sheet3Range,columnNumber,FALSE)))

This would just perform the search on the first sheet, if the value isn't there it will return an error, hence looking in the following sheet etc.

Bear in mind I've written the formula given your Excel is in English with commas (",") as separators, you might need to translate it in you default language and separators.

Upvotes: 2

Related Questions