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 36 37 38 39 40 41
| Option Compare Text
Sub Recopie_Valeurs()
Dim DerLig_F1 As Long, DerLig_F2 As Long, DerCol_F1 As Long
Dim F1 As Worksheet, F2 As Worksheet
Dim N°_Fact As Long, IMax As Long, i As Long
'Dim c As String
Application.ScreenUpdating = False
Set F1 = Sheets("1")
Set F2 = Sheets("2")
DerLig_F1 = F1.[A1000].End(xlUp).Row
DerLig_F2 = F2.[A1000].End(xlUp).Row
N°_Fact = F2.[A1]
ReDim Code(DerLig_F2) As String
ReDim Valeur(DerLig_F2) As Long
For i = 3 To DerLig_F2
If Cells(i, "A") = "" Then Exit For
Code(i) = F2.Cells(i, "A")
Valeur(i) = F2.Cells(i, "B")
IMax = i
Next i
DerCol_F1 = F1.[XFD1].End(xlToLeft).Column + 1
For i = 3 To IMax
Set c = F1.Columns("A").Find(Code(i), LookIn:=xlValues, lookat:=xlWhole)
If Not c Is Nothing Then
F1.Cells(c.Row, DerCol_F1) = Valeur(i)
End If
Next i
F1.Cells(1, DerCol_F1).NumberFormat = """F""0000"
F1.Cells(1, DerCol_F1) = N°_Fact
F2.[A1].NumberFormat = """F""0000"
F2.[A1].FormulaR1C1 = "=MAX('1'!R)+1"
Set c = Nothing
Set F1 = Nothing
Set F2 = Nothing
End Sub |
Partager