简体   繁体   中英

Use Vlookup() With VBA

I keep getting an error of

Object Required

running my syntax. This is the syntax that I have, but it is not successful. How can I write the Vlookup() value to my current worksheet cell T1?

Public Sub Test()
  Dim dblInfo
  dblInfo = Application.WorksheetFunction.VLookup("A2", Sheet1.Range("A2:F171"), 4, False)
  Range("T1").Select
  ActiveCell.FormulaR1C1 = dblInfo
End Sub

If you just want to enter the VLookup formula into T1

Range("T1") = "=VLookup(A2, Sheetname!A2:F171, 4, False)"

Otherwise, if you want to calculate the VLookup and then just enter the result...

Range("T1") = Application.WorksheetFunction.VLookup([A2], Sheetname.Range("A2:F171"), 4, False)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM