Optimisation VBA

Bonjour a vous toutes et tous,

Je vous met une vba userform qui fonctionne , cependant j'ai pu lire qu'il y a possibilité de pour optimisé . Car je ne sais pas si c'est la répétion de ligne qui ralenti l'exution de mon userform.

par avance merci

bien cordialement

Private Sub CommandButton1_Click()
Dim ligne As Long

If ComboBox1 = "" Then
MsgBox "Veuillez compléter au moins 1 intervenant ou exit SVP"
ComboBox1.SetFocus
Exit Sub
End If

If LabelDate1 = "" Then
MsgBox "Veuillez compléter date d'intervention ou exit SVP"

LabelDate1.SetFocus
Exit Sub
End If

If ComboBox11 = "" Then
MsgBox "Veuillez compléter temps passé de l'intervenant ou exit SVP"
ComboBox11.SetFocus
Exit Sub
End If

If ComboBox24 = "" Then
MsgBox "Veuillez compléter l'approbateur ou exit SVP"
ComboBox24.SetFocus
Exit Sub
End If
If LabelDate12 = "" Then
MsgBox "Veuillez compléter date de validation approbateur ou exit SVP"

LabelDate12.SetFocus
Exit Sub
End If
If ComboBox25.ListIndex < 0 Then
MsgBox "Veuillez sélectionner état d'intervention ou exit SVP"
ComboBox25.SetFocus
Exit Sub
End If

With ActiveSheet
'Intervenant'
.[E10] = ComboBox1.Value
.[E11] = ComboBox2.Value
.[E12] = ComboBox3.Value
.[E13] = ComboBox4.Value
.[E14] = ComboBox5.Value
.[E15] = ComboBox6.Value
.[E16] = ComboBox7.Value
.[E17] = ComboBox8.Value
.[E18] = ComboBox9.Value
.[E19] = ComboBox10.Value
.[E20] = ComboBox21.Value
.[J10] = ComboBox24.Value
.[L10] = ComboBox25.Value
'Date de saisie'
Range("G10").Value = LabelDate1
Range("G11").Value = LabelDate2
Range("G12").Value = LabelDate3
Range("G13").Value = LabelDate4
Range("G14").Value = LabelDate5
Range("G15").Value = LabelDate6
Range("G16").Value = LabelDate7
Range("G17").Value = LabelDate8
Range("G18").Value = LabelDate9
Range("G19").Value = LabelDate10
Range("G20").Value = LabelDate11
Range("K10").Value = LabelDate12

'Pointage heure'
.[H10] = ComboBox11.Value
.[H11] = ComboBox12.Value
.[H12] = ComboBox13.Value
.[H13] = ComboBox14.Value
.[H14] = ComboBox15.Value
.[H15] = ComboBox16.Value
.[H16] = ComboBox17.Value
.[H17] = ComboBox18.Value
.[H18] = ComboBox19.Value
.[H19] = ComboBox20.Value
.[H20] = ComboBox22.Value

End With

Call sommecouttotal
Call etat
Call Ok
ActiveSheet.Protect Password:="", DrawingObjects:=True, Contents:=True, Scenarios:=True
Unload UserForm16
End Sub

Private Sub CommandButton2_Click()

'Coix intervenants'
ComboBox1.ListIndex = -1
ComboBox2.ListIndex = -1
ComboBox3.ListIndex = -1
ComboBox4.ListIndex = -1
ComboBox5.ListIndex = -1
ComboBox6.ListIndex = -1
ComboBox7.ListIndex = -1
ComboBox8.ListIndex = -1
ComboBox9.ListIndex = -1
ComboBox10.ListIndex = -1
ComboBox21.ListIndex = -1
ComboBox24.ListIndex = -1
ComboBox25.ListIndex = -1

'Heure de pointage'
ComboBox11.ListIndex = -1
ComboBox12.ListIndex = -1
ComboBox13.ListIndex = -1
ComboBox14.ListIndex = -1
ComboBox15.ListIndex = -1
ComboBox16.ListIndex = -1
ComboBox17.ListIndex = -1
ComboBox18.ListIndex = -1
ComboBox19.ListIndex = -1
ComboBox20.ListIndex = -1
ComboBox22.ListIndex = -1
'Supprime intervenant'
ComboBox23.ListIndex = -1
'Date'

LabelDate1.Caption = ""
LabelDate2.Caption = ""
LabelDate3.Caption = ""
LabelDate4.Caption = ""
LabelDate5.Caption = ""
LabelDate6.Caption = ""
LabelDate7.Caption = ""
LabelDate8.Caption = ""
LabelDate9.Caption = ""
LabelDate10.Caption = ""
LabelDate11.Caption = ""

Range("E10:H20").ClearContents
Range("J10:L10").ClearContents
End Sub

Private Sub CommandButton3_Click()

ActiveSheet.Protect Password:="", DrawingObjects:=True, Contents:=True, Scenarios:=True
Unload UserForm16
End Sub

Private Sub CommandButton4_Click()
AjouterIntervenant.Show
End Sub

Private Sub CommandButton6_Click()
Unload UserForm16
Nouveau.Show
End Sub

Private Sub UserForm_Initialize()

Dim H As Range
'Remplir ComboBox1 avec la "Liste1"
ComboBox1.List = [Intervenants].Value
ComboBox2.List = [Intervenants].Value
ComboBox3.List = [Intervenants].Value
ComboBox4.List = [Intervenants].Value
ComboBox5.List = [Intervenants].Value
ComboBox6.List = [Intervenants].Value
ComboBox7.List = [Intervenants].Value
ComboBox8.List = [Intervenants].Value
ComboBox9.List = [Intervenants].Value
ComboBox10.List = [Intervenants].Value
ComboBox21.List = [Intervenants].Value

'Approbateur'
ComboBox24.List = [Aprobateur].Value
ComboBox25.List = [Suivie].Value

For Each H In [Temps]
ComboBox11.AddItem H.Text
ComboBox12.AddItem H.Text
ComboBox13.AddItem H.Text
ComboBox14.AddItem H.Text
ComboBox15.AddItem H.Text
ComboBox16.AddItem H.Text
ComboBox17.AddItem H.Text
ComboBox18.AddItem H.Text
ComboBox19.AddItem H.Text
ComboBox20.AddItem H.Text
ComboBox22.AddItem H.Text
Next
With ActiveSheet
'Intervenant'
ComboBox1.Value = .[E10].Text
ComboBox2.Value = .[E11].Text
ComboBox3.Value = .[E12].Text
ComboBox4.Value = .[E13].Text
ComboBox5.Value = .[E14].Text
ComboBox6.Value = .[E15].Text
ComboBox7.Value = .[E16].Text
ComboBox8.Value = .[E17].Text
ComboBox9.Value = .[E18].Text
ComboBox10.Value = .[E19].Text
ComboBox21.Value = .[E20].Text
ComboBox24.Value = .[J10].Text
ComboBox25.Value = .[L10].Text

'Heure'

ComboBox11.Value = .[H10].Text
ComboBox12.Value = .[H11].Text
ComboBox13.Value = .[H12].Text
ComboBox14.Value = .[H13].Text
ComboBox15.Value = .[H14].Text
ComboBox16.Value = .[H15].Text
ComboBox17.Value = .[H16].Text
ComboBox18.Value = .[H17].Text
ComboBox19.Value = .[H18].Text
ComboBox20.Value = .[H19].Text
ComboBox22.Value = .[H20].Text

'Date'

Me.LabelDate1.Caption = ActiveSheet.Range("G10").Value
Me.LabelDate2.Caption = ActiveSheet.Range("G11").Value
Me.LabelDate3.Caption = ActiveSheet.Range("G12").Value
Me.LabelDate4.Caption = ActiveSheet.Range("G13").Value
Me.LabelDate5.Caption = ActiveSheet.Range("G14").Value
Me.LabelDate6.Caption = ActiveSheet.Range("G15").Value
Me.LabelDate7.Caption = ActiveSheet.Range("G16").Value
Me.LabelDate8.Caption = ActiveSheet.Range("G17").Value
Me.LabelDate9.Caption = ActiveSheet.Range("G18").Value
Me.LabelDate10.Caption = ActiveSheet.Range("G19").Value
Me.LabelDate11.Caption = ActiveSheet.Range("G20").Value
Me.LabelDate12.Caption = ActiveSheet.Range("K10").Value

End With

Me.Left = Application.Left + Application.Width / 1.9 - Me.Width / 2
Me.Top = Application.Top + Application.Height / 2 - Me.Height / 2
CACHER_CROIX Me
Call CommandButton15_Click
End Sub

Private Sub CommandButton15_Click()
CACHER_BANDE_BLEUE Me
End Sub

Private Sub Image17_Click()
Unload UserForm16
End Sub
Private Sub LabelDate1_Click()
fmSTD_Calendrier.SelectDateCTRL LabelDate1
End Sub
Private Sub LabelDate2_Click()
fmSTD_Calendrier.SelectDateCTRL LabelDate2
End Sub
Private Sub LabelDate3_Click()
fmSTD_Calendrier.SelectDateCTRL LabelDate3
End Sub
Private Sub LabelDate4_Click()
fmSTD_Calendrier.SelectDateCTRL LabelDate4
End Sub
Private Sub LabelDate5_Click()
fmSTD_Calendrier.SelectDateCTRL LabelDate5
End Sub
Private Sub LabelDate6_Click()
fmSTD_Calendrier.SelectDateCTRL LabelDate6
End Sub
Private Sub LabelDate7_Click()
fmSTD_Calendrier.SelectDateCTRL LabelDate7
End Sub
Private Sub LabelDate8_Click()
fmSTD_Calendrier.SelectDateCTRL LabelDate8
End Sub
Private Sub LabelDate9_Click()
fmSTD_Calendrier.SelectDateCTRL LabelDate9
End Sub
Private Sub LabelDate10_Click()
fmSTD_Calendrier.SelectDateCTRL LabelDate10
End Sub
Private Sub LabelDate11_Click()
fmSTD_Calendrier.SelectDateCTRL LabelDate11
End Sub
'Approbateur'
Private Sub LabelDate12_Click()
fmSTD_Calendrier.SelectDateCTRL LabelDate12
End Sub

Private Sub Btn_Quitter_Fr_Click()
Unload UserForm16
End Sub

Private Sub Txt_tel_AfterUpdate()
Txt_tel.Text = Format(Txt_tel.Value, "## ### ###")
End Sub

Bonjour TEMAGOULTFARID,

Mauvaise section du forum, relance un topic dans la partie "Excel/VBA" et met un fichier anonymisé par pitié, c'est illisible 300 lignes de code.

Merci et bonne journée

Baboutz

Bonjour et merci pour votre retour

désolé , j'ai reposté au bon endroit avec le fichier .

bien cordialement

Bonjour à tous,

Mauvaise section du forum, relance un topic dans la partie "Excel/VBA" et met un fichier anonymisé par pitié, c'est illisible 300 lignes de code.

Il faut éviter de créer des doublons et juste attendre que la modération déplace le sujet (le doublon a donc été supprimé)

Cordialement,

Bonsoir,

Pour le coup on n'a plus de fichier : Sans le classeur KIVABIEN avec c'est mission impossible ! Merci de l'ajouter...

A+

Bonjour Galopin,

je le met en PJ

merci beaucoup

9fiche-vierge.zip (0.96 Mo)

Bonjour,

Un essai "non testé" ...

ric

Rechercher des sujets similaires à "optimisation vba"