PDA

View Full Version : macros



sksokh4
12-19-2023, 10:40 AM
can i use Vlookup on macros using 2 deferent worksheet? if yes what advice or thing i should watchout for?

Aussiebear
12-19-2023, 11:17 AM
Welcome to VBAX sksokh4. Yes you can. In its simplest form the formula is:

=VLOOKUP(What you want to look up, where you want to look for it, the column number in the range _
containing the value to return, return an Approximate or Exact match – indicated as 1/TRUE, or 0/FALSE).

Paul_Hossler
12-19-2023, 05:45 PM
can i use Vlookup on macros using 2 deferent worksheet? if yes what advice or thing i should watchout for?


Yes

Basic example


Option Explicit

Sub Demo()
Worksheets("Sheet1").Range("C6").Value = _
Application.WorksheetFunction.VLookup(Worksheets("Sheet1").Range("B3").Value, Worksheets("Sheet2").Range("A:B"), 2, False)
End Sub