jeudi 30 janvier 2020

VB vlookup in different sheet for certain values

can you please help me with a vlookup in a different sheet only for certain values? I have tried for each, for i, different if's and so on.

I need the vba to bring in Sheet2 values from a Sheet1, but only for rows that have the value "De rediscutat" in a different column in Sheet2.

Below you have the code i wrote for this function:

Dim result As String
Dim Sheet2 As Worksheet
Set Sheet2 = ActiveWorkbook.Sheets("Sheet2")
Set MyRange = Range("X2:X800")
If MyRange = "De rediscutat" Then
Worksheets("Sheet2").Range("N2:N694").Formula = Application.WorksheetFunction.VLookup(Sheet2.Range("I2:I694"), Sheet1.Range("G2:M500"), 7, False)
End If
End Sub```

Thanks!

Aucun commentaire:

Enregistrer un commentaire