Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionOption Explicit Dim OldWidth As Integer Dim OldHeight As Integer Dim trouve As Boolean Dim ex As New Excel.Application Dim i As Integer Private Sub Cmd1_Click() ex.Application.ScreenUpdating = True ex.Worksheets("TriSuppressionDoublon").Range("B7").Sort _ key1:=ex.Worksheets("TriSuppressionDoublon").Range("B8"), _ Order1:=xlAscending, Header:=xlGuess Set ex.MaCell = ex.eWorksheets("TriSuppressionDoublon").Range("B7") Do While Not IsEmpty(ex.MaCell) Set ex.MaCellSuite = ex.MaCell.Offset(1, 0) If ex.MaCellSuite.Value = ex.MaCell.Value Then ex.MaCell.EntireRow.Delete End If Set ex.MaCell = ex.MaCellSuite Loop ex.Sheets("TriSuppressionDoublon").Select Range("B7:B65536").Select Selection.Copy ex.Sheets("Workstations with SMS Installed").Select Range("F7:F65536").Select ex.ActiveSheet.Paste trouve = False Set ex.cellule1 = ex.Worksheets("Workstations with SMS Installed").Range("A7") Set ex.cellule2 = ex.Worksheets("Workstations with SMS Installed").Range("D7") Set ex.cellule3 = ex.Worksheets("Workstations with SMS Installed").Range("F7") 'on boucle sur la colonne A, jusqu'à la première cellule vide : While Not IsEmpty(ex.cellule1) 'on teste l'égalité des 3 cellules 'si elles sont égales, alors on va rechercher la date correspondante dans l'autre feuille If (ex.cellule1.Value ex.cellule2.Value) And (ex.cellule2.Value ex.cellule3.Value) Then Set ex.celluleRecherche = ex.Worksheets("TriSuppressionDoublon").Range("B7") While Not IsEmpty(ex.celluleRecherche) And trouve = False If ex.celluleRecherche.Value = ex.cellule1.Value Then trouve = True ex.cellule1.Offset(0, 2).Value = ex.celluleRecherche.Offset(0, -1).Value End If Set ex.celluleRecherche = ex.celluleRecherche.Offset(1, 0) Wend 'sinon, on descend les cellules de F d'une ligne Else 'on recherche la plage de données à copier i = 0 While Not IsEmpty(ex.cellule3.Offset(i, 0)) i = i + 1 Wend Range("F" & ex.cellule3.Row & ":F" & ex.cellule3.Offset(i - 1, 0).Row).Select Selection.Copy ex.cellule3.Offset(1, 0).Select ex.ActiveSheet.Paste ex.cellule3.Value = "" End If Set ex.cellule1 = ex.cellule1.Offset(1, 0) Set ex.cellule2 = ex.cellule2.Offset(1, 0) Set ex.cellule3 = ex.cellule3.Offset(1, 0) Wend ex.Application.ScreenUpdating = True End Sub Public Sub Cmd2_Click() Dim Form As Form For Each Form In Forms Unload Form Next Form ex.Visible = True Set ex = Nothing End Sub Private Sub Cmd3_Click() ex.Workbooks.Add ex.Visible = True End Sub Private Sub Form_Load() OldWidth = Width OldHeight = Height End Sub Private Sub Form_Resize() On Error Resume Next Dim XCoeff As Single Dim YCoeff As Single Dim Controle As Control XCoeff = Width / OldWidth YCoeff = Height / OldHeight For Each Controle In Me Controle.Move Controle.Left * XCoeff, Controle.Top * YCoeff, Controle.Width * XCoeff, Controle.Height * YCoeff Next OldWidth = Width OldHeight = Height End Sub