Bonjour,
vlookup
https://www.developpez.net/forums/d4...l/vlookup-vba/
A+
Version imprimable
Bonjour,
vlookup
https://www.developpez.net/forums/d4...l/vlookup-vba/
A+
Bonjour Vincent,
1 - Ici, "Selection" n'est pas affecté.
2 - Libérer les variables affectées à des objets, après utilisation
3 - Utiliser le bloc With afin de rendre le code plus lisible
A adapter, le cas éventuel
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35 Option Explicit Sub remplissage(nom_feuille_origine, num_colonne_origine, nom_feuille_destination, num_colonne_destination) Dim compteur2, max2 As Integer Dim ref1 As String Dim range1, PlageDeRecherche As Range Dim range2 As Integer max2 = max_ligne(nom_feuille_destination, 1) Set PlageDeRecherche = Sheets(nom_feuille_origine).Columns(1) For compteur2 = 3 To max2 ref1 = Sheets(nom_feuille_destination).Cells(compteur2, 1).Value Set range1 = PlageDeRecherche.Cells.Find(what:=ref1, LookAt:=xlWhole) With Sheets(nom_feuille_destination).Cells(compteur2, num_colonne_destination) If range1 Is Nothing Then .Value = "Pas trouvé" .Interior.Color = RGB(255, 0, 0) Else range2 = range1.Row .Value = Sheets(nom_feuille_origine).Cells(range2, num_colonne_origine).Value End If End With Set range1 = Nothing Next compteur2 Set PlageDeRecherche = Nothing End Sub