Re Hellboy
OK
Mais excuse moi, en commentaire, pourquoi puisque ce n'est pas une commande et cette commande est deja dans l'USB, à moins qu'elle ne soit pas placé au bonne endroit
Option Explicit
Const T As String = 'FORMULAIRE'
Private Feuille As Worksheet
Private Ligne As Integer
Private Ini As Boolean
Private Sub UserForm_Initialize()
Dim WS As Worksheet
For Each WS In ThisWorkbook.Worksheets
If WS.Name <> 'Interface' Then
ComboBox1.AddItem WS.Name
End If
Next
With Me
.TextBox1 = Date
.ComboBox1.MatchRequired = True
.ComboBox2.MatchRequired = True
.Caption = T
End With
End Sub
Private Sub ComboBox1_Change()
Dim TabBa As Variant
Dim LastBA As Long
If Ini = True Then Exit Sub
On Error GoTo Out
Set Feuille = ThisWorkbook.Worksheets(CStr(Me.ComboBox1))
With Feuille
TabBa = .Range(.Range('A2'), .Range('A65536').End(xlUp))
End With
Me.ComboBox2.List = TabBa
Exit Sub
Out:
MsgBox 'La Feuille ' & Me.ComboBox1 & ' n'existe pas'
End Sub
Private Sub ComboBox2_Change()
Ligne = Me.ComboBox2.ListIndex + 2
On Error Resume Next
Me.TextBox2.Value = Sheets(Me.ComboBox1.Value).Cells(Ligne, 12)
On Error GoTo 0
End Sub
Private Sub CmdOK_Click()
If Not IsDate(Me.TextBox1) Then
MsgBox 'Indiquez une date Correct', vbCritical
Exit Sub
End If
If Me.ComboBox1.ListIndex = -1 Then
MsgBox 'Sélectionnez un Mois', vbCritical
Exit Sub
End If
If Me.ComboBox2.ListIndex = -1 Then
MsgBox 'Sélectionnez un BA', vbCritical
Exit Sub
End If
If Me.TextBox2 = '' Then
MsgBox 'Indiquez un Numéro de Facture', vbCritical
Exit Sub
End If
With Feuille
' Pose de X dans les colonnes 'G, H, I'
.Range('G' & Ligne).Value = 'X'
.Range('H' & Ligne).Value = 'X'
.Range('I' & Ligne).Value = 'X'
' On colorie la ligne enregistrée
With .Range('A' & Ligne & ':M' & Ligne)
With .Interior
.ColorIndex = 19
.Pattern = xlSolid
End With
End With
.Range('M' & Ligne) = TextBox1
.Range('L' & Ligne) = TextBox2
End With
ReInitialisation
Ini = False
End Sub
Private Sub ReInitialisation()
Ini = True
With Me
.ComboBox1 = ''
.ComboBox2.Clear
.TextBox2 = ''
End With
End Sub
Private Sub CmdSortir_Click()
Unload UserForm2
End Sub
Merci