Problème avec UserForm avec liste déroulante
Résolu
laura54960
Messages postés
17
Date d'inscription
Statut
Membre
Dernière intervention
-
laura54960 Messages postés 17 Date d'inscription Statut Membre Dernière intervention -
laura54960 Messages postés 17 Date d'inscription Statut Membre Dernière intervention -
A voir également:
- Problème avec UserForm avec liste déroulante
- Liste déroulante excel - Guide
- Liste déroulante en cascade - Guide
- Liste déroulante google sheet - Accueil - Guide bureautique
- Liste code ascii - Guide
- Site dangereux liste - Guide
1 réponse
Bonjour,
code un peu optimise, a vous de tester
'dans un module
'userform
code un peu optimise, a vous de tester
'dans un module
Public i As Integer Sub Calcul() Dim hanc As String Dim hnouv As String Dim datechg As Date Dim datedeb As Date Dim datefin As Date Dim date1 As Date i = 21 Do While date1 - 1 < datefin With Worksheets("Bilan") hanc = .Cells(i, 6).Value hnouv = .Cells(i, 9).Value datechg = .Cells(7, 7).Value datedeb = .Cells(13, 7).Value datefin = .Cells(15, 7).Value date1 = .Cells(i, 4).Value If hnouv = "RH" Or hnouv = "G" Or hnouv = "R" Or hnouv = "JRTT" Then .Cells(i, 18).Value = 0 ElseIf hnouv = "J" And hanc = "RH" Or hnouv = "J" And hanc = "R" Or hnouv = "J" And hanc = "G" Or hnouv = "J" And hanc = "JRTT" Then .Cells(i, 18).Value = 12.25 ElseIf hnouv = "J" And hanc = "DEMIJRTT" Then .Cells(i, 18).Value = 7 ElseIf hnouv = "M" And hanc = "RH" Or hnouv = "M" And hanc = "R" Or hnouv = "M" And hanc = "G" Or hnouv = "M" And hanc = "JRTT" Then .Cells(i, 18).Value = 14.25 ElseIf hnouv = "M" And hanc = "DEMIJRTT" Then .Cells(i, 18).Value = 9 ElseIf hnouv = "M" And hanc = "J" Then .Cells(i, 18).Value = 1.67 ElseIf hnouv = "A" And hanc = "RH" Or hnouv = "A" And hanc = "R" Or hnouv = "A" And hanc = "G" Or hnouv = "A" And hanc = "JRTT" Then .Cells(i, 18).Value = 14.88 ElseIf hnouv = "A" And hanc = "DEMIJRTT" Then .Cells(i, 18).Value = 8.75 ElseIf hnouv = "DEMIJRTT" And hanc = "RH" Or hnouv = "DEMIJRTT" And hanc = "R" Or hnouv = "DEMIJRTT" And hanc = "G" Or hnouv = "DEMIJRTT" And hanc = "JRTT" Then .Cells(i, 18).Value = 5.25 End If If hnouv = "N" Then Userform1.Show End If End With i = i + 1 '???????? date1 = date1 + 1 Loop End Sub
'userform
Private Sub OK_Click() Dim date1 As Date Dim hnouv As String Dim datechang As Date mavariable = ListBox1.Value With Worksheets("Bilan") datechang = .Cells(7, 7).Value date1 = .Cells(i, 4).Value hnouv = .Cells(i, 9).Value If hnouv = "N" Then Label2.Caption = date1 If mavariable = "N sur Repos - Repos" Then .Cells(i, 18).Value = 23.62 ElseIf mavariable = "N sur Repos - Semaine" Then .Cells(i, 18).Value = 20.58 ElseIf mavariable = "N sur Semaine - Repos" Then .Cells(i, 18).Value = 21.96 ElseIf mavariable = "N sur 1/2JRTT - Repos" Then .Cells(i, 18).Value = 16.25 ElseIf mavariable = "N sur 1/2JRTT - Semaine" Then .Cells(i, 18).Value = 14.67 ElseIf mavariable = "N sur J" Then .Cells(i, 18).Value = 5 ElseIf mavariable = "N sur M - A" Then .Cells(i, 18).Value = 3 End If End If End With Unload Me End Sub Private Sub Userform_Initialize() date1 = Worksheets("Bilan").Cells(i, 4).Value Label2.Caption = date1 End Sub
Merci f894009 pour ta réponse. J'ai testé sur mon programme et j'ai simplement du modifier tous les "i" qui apparaissaient, en "calcul.i" pour que la portée soit publique.
Et super, ça fonctionne ! Merci beaucoup !
Je vais continuer à tester les calculs pour vérifier si tout correspond bien.
Encore merci !