Option Explicit
Public WithEvents TxtB As MSForms.TextBox
Dim Ws As Worksheet
Dim SelectedIndex As Integer
Dim cls(1 To 15) As New Modifier
Const fmt1 = "#,##0.00;-#,##0.00"
Const fmt2 = "#,##0.00 €;-#,##0.00 €"
[COLOR=rgb(97, 189, 109)]
Cela grâce à la déclaration "Public "[/COLOR]
Private Sub Quitter_Click()
Unload Me
Accueil.Show 0
End Sub
Private Sub TextBox14_change()
TextBox14 = Format(TextBox14, fmt2)
End Sub
[COLOR=rgb(97, 189, 109)]
Private Sub TextBox15_Change()
TextBox15 = Format(TextBox15, fmt2)
End Sub
Private Sub TxtB_Change()
Dim chn$, mem#, i As Byte
If Right$(TxtB, 1) = "." Then TxtB = Replace$(TxtB, ".", ",")
[COLOR=rgb(97, 189, 109)]
For i = 2 To 13
[COLOR=rgb(97, 189, 109)]
With Modifier.Frame1.Controls("TextBox" & i)
chn = .Value: If IsNumeric(chn) Then mem = mem + CDbl(chn)
End With
Frame1.Controls("TextBox" & i) = Format(chn, fmt1)
Next i
Modifier.Frame1.TextBox14 = mem
[COLOR=rgb(97, 189, 109)]
End Sub
Private Sub UserForm_Activate()
Dim ctrl, MaSomme#, MC%, J&, MPL&, MDL&, a&
ComboBox2.ColumnCount = 1
ComboBox2.List() = Array("Civilité", "Mr", "Mme")
Set Ws = Sheets("Controle")[COLOR=rgb(97, 189, 109)]
With Me.ComboBox1
For J = 2 To Ws.Range("A" & Rows.Count).End(xlUp).Row
.AddItem Ws.Range("C" & J) & " - " & Format(Ws.Range("A" & J), "0# ## ## ## ##")
Next J [COLOR=rgb(97, 189, 109)]
End With
For Each ctrl In Frame1.Controls [COLOR=rgb(97, 189, 109)]
If TypeName(ctrl) = "TextBox" And ctrl.Name <> "TextBox14" Then
a = a + 1: Set cls(a).TxtB = ctrl [COLOR=rgb(97, 189, 109)]
End If
Next ctrl
Worksheets("Controle").Select
MC = 16
MPL = 2
MDL = Cells(Rows.Count, "P").End(xlUp).Row - 1
MaSomme = 0
For J = MPL To MDL
MaSomme = MaSomme + Cells(J, MC)
Next J
TextBox15 = MaSomme [COLOR=rgb(97, 189, 109)]
End Sub
Private Sub ComboBox1_Change()
Dim Ligne&, i As Byte
SelectedIndex = ComboBox1.ListIndex
If ComboBox1.ListIndex = -1 Then
ComboBox2.ListIndex = -1
For i = 1 To 14
Controls("TextBox" & i) = "" [COLOR=rgb(97, 189, 109)]
Next i
Else
Ligne = ComboBox1.ListIndex + 2
ComboBox2 = Ws.Cells(Ligne, "B")
Textbox1 = Ws.Cells(Ligne, "C")
For i = 2 To 14
Controls("TextBox" & i) = Format(Ws.Cells(Ligne, i + 2), fmt1)
[COLOR=rgb(97, 189, 109)]
Next i
End If
If ComboBox1.ListIndex <> -1 Then Cells(ComboBox1.ListIndex + 2, 1).Select
[COLOR=rgb(97, 189, 109)]
End Sub
Private Sub Valider_Click()
[COLOR=rgb(97, 189, 109)]
Dim MaSomme#, MC%, Ligne&, MPL&, MDL&
If MsgBox("Etes-vous certain de vouloir mofifier la fiche?", vbYesNo, "Demande de confirmation") = vbYes Then
If SelectedIndex = -1 Then Exit Sub
Ligne = SelectedIndex + 2 [COLOR=rgb(97, 189, 109)]
Ws.Cells(Ligne, "B") = ComboBox2
Ws.Cells(Ligne, 3) = Textbox1[COLOR=rgb(97, 189, 109)]
Ws.Columns("D:O").NumberFormat = fmt1 [COLOR=rgb(97, 189, 109)]
Ws.Columns("P").NumberFormat = fmt2 [COLOR=rgb(97, 189, 109)]
On Error Resume Next [COLOR=rgb(97, 189, 109)]
Ws.Range("D" & Ligne) = Trim$(TextBox2) * 1 [COLOR=rgb(97, 189, 109)]
Ws.Range("E" & Ligne) = Trim$(TextBox3) * 1
Ws.Range("F" & Ligne) = Trim$(TextBox4) * 1
Ws.Range("G" & Ligne) = Trim$(TextBox5) * 1
Ws.Range("H" & Ligne) = Trim$(TextBox6) * 1
Ws.Range("I" & Ligne) = Trim$(TextBox7) * 1
Ws.Range("J" & Ligne) = Trim$(TextBox8) * 1
Ws.Range("K" & Ligne) = Trim$(TextBox9) * 1
Ws.Range("L" & Ligne) = Trim$(TextBox10) * 1
Ws.Range("M" & Ligne) = Trim$(TextBox11) * 1
Ws.Range("N" & Ligne) = Trim$(TextBox12) * 1
Ws.Range("O" & Ligne) = Trim$(TextBox13) * 1
Ws.Range("P" & Ligne).Formula = "=SUM(D" & Ligne & ":O" & Ligne & ")"
Err.Clear [COLOR=rgb(97, 189, 109)]
End If
MC = 16
MPL = 2
MDL = Cells(Rows.Count, "P").End(xlUp).Row - 1
For Ligne = MPL To MDL
MaSomme = MaSomme + Cells(Ligne, MC)
Next Ligne
TextBox15 = MaSomme
Worksheets("Top 10 Conso").Select: Tri [COLOR=rgb(97, 189, 109)]
Dans le module "Tri", tu as rajouté "Application.ScreenUpdating=0" qui permet de faire le tri sans que l
Worksheets("Controle").Select [COLOR=rgb(97, 189, 109)]
En Sub
Je reste dans l
Soan merci encore milles fois pour ton aide. J
Dans l