I am trying to get this result:
Currently my vbc script gives me this:
This is the first sheet where the vlookup is made from
Sub Suivi()
With ActiveSheet
.Unprotect Password:="capreit"
Rows("2:" & Rows.Count).ClearContents
Worksheets("Suivi Déménagement").Cells.Borders.LineStyle = xlNone
Dim i As Integer
j = 2
For i = 4 To Sheets("Tableau").Range("A4").SpecialCells(xlLastCell).Row
If Sheets("Tableau").Cells(i, 2).Value = "Nouveau locataire" Or Sheets("Tableau").Cells(i, 2).Value = "Décès" Or Sheets("Tableau").Cells(i, 2).Value = "Skip" And Evaluate("OR(ISNUMBER(MATCH({""*-*""},{""" & Sheets("Tableau").Cells(i, 1).Value & """},0)))") Then
Sheets("Suivi Déménagement").Cells(j, 1) = Sheets("Tableau").Cells(i, 1)
Sheets("Suivi Déménagement").Cells(j, 2).Formula = "=IFERROR(VLookup($A2,Tableau!$A:$T,4,FALSE),"""")"
Sheets("Suivi Déménagement").Cells(j, 3).Formula = "=IFERROR(VLookup($A2,Tableau!$A:$T,3,FALSE),"""")"
Sheets("Suivi Déménagement").Cells(j, 4).Formula = "=IFERROR(VLookup($A2,Tableau!$A:$T,2,FALSE),"""")"
Sheets("Suivi Déménagement").Cells(j, 5).Formula = "=IFERROR(VLookup($A2,Tableau!$A:$T,18,FALSE),"""")"
Sheets("Suivi Déménagement").Cells(j, 6).Formula = "=IFERROR(VLookup($A2,Tableau!$A:$T,19,FALSE),"""")"
j = j + 1
End If
Next i
You're using the same vlookup with the same value and the same criteria but expecting different results.
I believe your specific problem is with "$A2". This should be dynamic. The next row should be $A3, then $A4, and so on.
You can achieve this by treating your vlookup as a string. Break it after the $A to use your variable then rejoin the string.
For example: "...RROR(VLookup($A" & j & ", Tabl...."
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.