Bonjour,
voici mon problème: j ai mis dans mon userform un bouton "ajouter" qui permettra de remplir 2 tableaux différents selon une condition (boutons d'option) a travers mon formulaire userform . si la condition est true remplir le 1ier tableau sinon remplir le 2ieme. Le problème c'est que le code que j'ai écrit pour remplir le 1ier tableau (sous la condition marche=true) et incrémenter ses ligne marche bien mais une fois que j'écrit le même code pour remplir le 2ieme tableau ( condition arret=true) ça marche pas. si quelqu' un pourrai m'aider a résoudre ce problème j'en serrais très reconnaissante.
voici mon code:
'Bouton ajouter
Private Sub CommandButton2_Click()
Dim sourceCol As Integer, rowCount As Integer, currentRow As Integer
Dim currentRowValue As String
If stade.Value = "" Then
MsgBox ("Choisissez un stade")
ElseIf marche = True Then
If equipement.Value = "" Or HTP.Value = "" Or HM.Value = "" Or QUO.Value = "" Or CUO.Value = "" Or QCSP.Value = "" Or CCSP.Value = "" Or nombre.Value = "" Then
MsgBox ("Informations insuffisantes")
Else
sourceCol = 2 'column B has a value of 2
rowCount = Sheets("simulation").Cells(Rows.Count, sourceCol).End(xlUp).Row
'for every row, find the first blank cell and select it
For currentRow = 4 To rowCount
currentRowValue = Sheets("simulation").Cells(currentRow, sourceCol).Value
If IsEmpty(currentRowValue) Or currentRowValue = "" Then
Sheets("simulation").Cells(currentRow, sourceCol).Value = equipement
Sheets("simulation").Cells(currentRow, sourceCol + 1).Value = nombre
Sheets("simulation").Cells(currentRow, sourceCol + 2).Value = HTP
Sheets("simulation").Cells(currentRow, sourceCol + 3).Value = HM
Sheets("simulation").Cells(currentRow, sourceCol + 4).Value = QUO
Sheets("simulation").Cells(currentRow, sourceCol + 5).Value = QCSP
Exit For
End If
Next
End If
End If
'ajouter equipement en arret
If arret = True Then
sourceCol = 1 'column a has a value of 1
rowCount = Cells(Rows.Count, sourceCol).End(xlUp).Row
'for every row, find the first blank cell and select it
For currentRow = 25 To rowCount
currentRowValue = Cells(currentRow, sourceCol).Value
If IsEmpty(currentRowValue) Or currentRowValue = "" Then
Sheets("simulation").Cells(currentRow, sourceCol).Value = equipement
Sheets("simulation").Cells(currentRow, sourceCol + 1).Value = nombre
Sheets("simulation").Cells(currentRow, sourceCol + 2).Value = HA
Sheets("simulation").Cells(currentRow, sourceCol + 3).Value = DEBIT
Sheets("simulation").Cells(currentRow, sourceCol + 4).Value = COUT
Exit For
End If
Next
End If
End Sub