bonjour, j'ai un tableau dont les dimensions peuvent varier. j'ai besoin de rajouter une colonne à la fin avec l'équivalent de la fonction RechercheV
voilà le code que j'ai écrit mais la boucle For/next ne fonctionne pas avec ma condition If.
Quelqu'un aurait-il une idée? MERCI!!!

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Sub recherchev_loc()
Workbooks("fichier_du_jour_20200505.xlsx").Worksheets("Kinaxis").Activate
Dim dercol As Integer
Dim derlig As Integer
Dim LigDep As Integer
dercol = ActiveSheet.Cells(1, Cells.Columns.Count).End(xlToLeft).Column 'dercol = calcul du nombre de colonnes du tableau
derlig = ActiveSheet.Range("B1").End(xlDown).Row 'derlig = calcul du nombre de ligne du tableau
For LigDep = 2 To derlig + 1
Cells(LigDep, dercol + 1).Select
If Range("N" & LigDep).Value <> "" Then
Cells(LigDep, dercol + 1).Value = WorksheetFunction.VLookup(Range("N" & LigDep).Value, Workbooks("BD_Markets_Locactions_Regions.xlsx").Sheets("Plants & Loc").Range("PlantsLoc"), 2, False)
End If
Cells(LigDep, dercol + 1).Value = "NA"
Next
 
End Sub