1

Can anyone tell me why is this not working? This stop working my macro and an error message appears

Sh.Cells(2, 13).Formula = WorksheetFunction.VLookup(Sh.Cells(2, 6) & " - " & Sh.Cells(2, 8), Worksheets("Licenciaturas").Range("H2:K2928"), 4, False)

enter image description here

Thanks!

someOne
  • 1,975
  • 2
  • 14
  • 20
StackJP
  • 541
  • 1
  • 5
  • 14

1 Answers1

2

Are you trying to add it as a formula to the cell, or just return the result of the VLookup and place that in the cell?

Your code looks like it's trying to do a bit of both.

If you want a formula to appear in your sheet use:

Sh.Cells(2, 13).FormulaR1C1 = "=VLOOKUP(R2C6 & "" - "" & R2C8, 'Licenciaturas'!R2C8:R2928C8,4,FALSE)"

The formula will appear as: =VLOOKUP($F$2 & " - " & $H$2, Licenciaturas!$H$2:$H$2928,4,FALSE)

Darren Bartrup-Cook
  • 18,362
  • 1
  • 23
  • 45