Bonjour à tous,
Dans un Userform j'ai toute une série de CheckBox. Je voudrais en rajouter une, dont l'information devrai se retrouver dans une nouvelle colonne créé entre la colonne "I" et la colonne "K" de ma feuille actuelle.
Ajouter la case à cocher je sais faire. Par contre comment modifier mon code:
Public Derlig As Integer
Private CTRL As control
Private L&, I&
Private Sub ComboBox1_Change()
Dim J&, k&
On Error Resume Next
If Flag Then Exit Sub
With Feuil1
k = Application.Match(ComboBox1, .Columns(1), 0)
On Error GoTo 0
If k <> 0 Then
L = ComboBox1.ListIndex + 12
For I = 1 To 26
Controls("CheckBox" & I) = IIf(.Cells(L, I + 4) = "", 0, 1)
Controls("CheckBox" & I).BackColor = IIf(Controls("CheckBox" & I), vbGreen, vbWhite)
Next
TextBox1 = .Cells(L, 4)
End If
End With
Me.Height = 600
Me.Width = 700
Me.Top = Application.Height / 2 - Me.Height / 2
Me.Left = Application.Width / 2 - Me.Width / 2
Enregist.SetFocus
End Sub
Private Sub CommandButton2_Click()
Unload Me
End Sub
Private Sub CommandButton3_Click()
PERMIS_ET_FORMATIONS.PrintForm
Public Sub Enregist_Click()
With Feuil1
k = Application.Match(ComboBox1, .Columns(1), 0)
L = ComboBox1.ListIndex + 12
For I = 1 To 26
If k <> 0 Then
.Cells(L, I + 4) = IIf(Controls("CheckBox" & I) = 0, "", "ü")
Else
.Cells(Derlig, I + 4) = IIf(Controls("CheckBox" & I) = 0, "", "ü")
End If
Next
.Cells(L, 4) = TextBox1.Value
End With
Unload Me
PERMIS_ET_FORMATIONS.Show 0
End Sub
Private Sub Nouv_valid_Click()
Unload Me
Nouveau.Show 0
End Sub
Private Sub UserForm_Initialize()
With Feuil1
lig = .Range("A" & Rows.Count).End(xlUp).Row
If lig < 12 Then Exit Sub
If lig = 12 Then ComboBox1.AddItem .Range("A12") Else ComboBox1.List = .Range("A12:A" & lig).Value
End With
End Sub
Private Sub CommandButton4_Click()
Dim I As Byte
Application.ScreenUpdating = False
With Me.ComboBox1
If .Value <> "" Then
If MsgBox("Attention, vous allez débarquer " & .List(.ListIndex) & vbLf & _
"Confirmez-vous ce débarquement?", vbYesNoCancel) = vbYes Then
Sheets("LUTIN").Cells(.ListIndex + 12, 1).Resize(1, 27).ClearContents
Flag = True: .RemoveItem (.ListIndex)
End If
End If
If Flag Then
Call Tri_Base
Me.ComboBox1 = "": Me.ComboBox1 = ""
For I = 1 To 26
Me.Controls("CheckBox" & I) = 0
Me.Controls("CheckBox" & I).BackColor = vbWhite
Next I
End If
End With
Flag = False
Unload Me
PERMIS_ET_FORMATIONS.Show 0
End Sub
Merci par avance