' Varable déclaré globale, mais juste pour ce Module Feuille
' Ça évite de la déclarer pour chaque procédure de CommandButton
Private intRef As Integer
Private Sub CommandButton1_Click()
Call Clone_Cell(ByVal 1) ' Passage d'un paramétre a la procédure qui étais la même pour tous
End Sub
Private Sub CommandButton2_Click()
Call Clone_Cell(ByVal 2)
End Sub
Private Sub CommandButton3_Click()
Call Clone_Cell(ByVal 3)
End Sub
Private Sub CommandButton4_Click()
Call Clone_Cell(ByVal 0)
End Sub
Private Sub Clone_Cell(ByVal intRef As Integer)
Dim Plage As Range 'déclare la variable Plage
Dim Dest As Range 'déclare la variable Dest
Dim Cel As Range 'deçlare la variable Cel
'définit la variable Plage
With Sheets('SUIVI DEVIS')
Set Plage = .Range('F2:F' & .Range('F65536').End(xlUp).Row)
End With
'définit la variable Dest
With Sheets('RELANCE')
If .Range('A3').Value = '' Then
Set Dest = .Range('A3')
Else
Set Dest = .Range('A65536').End(xlUp).Offset(1, 0)
End If
End With
For Each Cel In Plage 'bopucle sur toutes les cellules Cel de la plage 'Plage'
If Cel.Value = intRef Then 'condition : si la cellule Cel
Cel.EntireRow.Copy Destination:=Dest 'copie la ligne entoère vers la destination Dest
Set Dest = Dest.Offset(1, 0) 'redéfinit la variable Dest
End If 'fin de la condition
Next Cel 'prochaine cellule de la plage 'Plage'
Dim date_auj As Date 'ligne pour collorer en rouge la police
date_auj = Date
For I = 2 To Range('E65536').End(xlUp).Row
If Cells(I, 5).Value < date_auj Then 'premiére ligne 5 eme colonne
Cells(I, 5).Font.ColorIndex = 3
End If
Next I
End Sub