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!

3
  • Edited the question
    – StackJP
    Sep 9, 2016 at 11:12
  • Have you looked at this?!
    – someOne
    Sep 9, 2016 at 11:13
  • since you are using the WorksheetFunction of VLookup, you don't need the ".Formula" , you can just use 'Sh.Cells(2, 13) = ....'
    – Shai Rado
    Sep 9, 2016 at 11:15

1 Answer 1

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)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.