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
| Private Sub CommandButton1_Click()
On Error GoTo Error_Handler
Dim cible As String
Dim j, k As Integer
j = 5: k = 3
With Sheets("Activité")
Range(Cells(j, k), Cells(j, k)).Select
Do While True
If UCase(ActiveCell.Offset(0, 16)) Like UCase("x") Then
j = ActiveCell.Offset(0, 16).Row
cible = Sheets("BDD").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Address
Range(Cells(j, 3), Cells(j, 6)).Copy Destination:=Sheets("BDD").Range(cible)
Application.CutCopyMode = False
Sheets("Activité").Activate
End If
ActiveCell.Offset(1, 0).Activate
If ActiveCell = "" Then Exit Do
Loop
End With
Sheets("BDD").Select
Error_Handler_Exit:
Exit Sub
Error_Handler:
MsgBox "L'erreur suivante s'est produite:" & vbCrLf & vbCrLf & _
"Numéro: " & Err.Number & vbCrLf & _
"Source: CommandButton1" & vbCrLf & _
"Description: " & Err.Description, _
vbCritical, "Erreur de procédure!"
Resume Error_Handler_Exit
End Sub |
Partager