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
| Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 7 And Target.Row > 9 And Target.Value <> "" Then
Application.EnableEvents = False
CopierData Target.Value
Application.EnableEvents = True
End If
End Sub
Private Sub CopierData(Valeur As String)
Dim nbLignes As Long
'Effacer les données de 1tip
nbLignes = Sheets("1tip").Cells(Rows.Count, "A").End(xlUp).Row
If nbLignes > 9 Then Sheets("1tip").Range("A10:G" & nbLignes).ClearContents
Sheets("Book-1").AutoFilterMode = False
Sheets("Book-1").Rows(6).AutoFilter Field:=7, Criteria1:=Valeur
nbLignes = Sheets("Book-1").Cells(Rows.Count, "G").End(xlUp).Row
If nbLignes > 8 Then
'Copie des premières colonnes
Sheets("Book-1").Range("A9:E" & nbLignes).Copy
Sheets("1tip").Range("A10").PasteSpecial
Sheets("Book-1").Range("G9:H" & nbLignes).Copy
Sheets("1tip").Range("G10").PasteSpecial
'Inscription formule en B
nbLignes = Sheets("1tip").Cells(Rows.Count, "A").End(xlUp).Row
Sheets("1tip").Range("B10:B" & nbLignes).Formula = "=LEFT(A10,1)"
End If
End Sub |
Partager