Bonjour,
j'ai récupéré et modifié le code ci dessous pour lire la première ligne de l'onglet, qui contient le nom de toutes les box de mon formulaire. Le but étant de pouvoir insérer une colonne, sans avoir à renuméroter les box pour coller au fichier.
J'ai fini par revenir à ma version initiale, en récupérant le nom excat défini dans l'userform.
Si qq'un pouvait m'aider à franchir le dernier pas....
Merci
Frédéric
Private Sub CreerAna()
Dim i As Integer
Dim C As Integer
Dim SelectAna As String
Dim Ctrl As Control
If CDV = True Then
SelectAna = "DV"
Else
SelectAna = "OUI"
End If
WsBase.Cells(Ligne, 2) = NumLT
WsBase.Cells(Ligne, 3) = DateLimite
'For Each Ctrl In Me.Controls
For C = 4 To 8 'col - 3
' Set Ctrl = Controls(Range("B3, G3").Select) '==> Message erreur
'
' If TypeOf Ctrl Is MSForms.TextBox Then
' 'If TypeName(Ctrl) = "TextBox" Then
' Cells(Ligne, C) = Ctrl
' ElseIf TypeOf Ctrl Is MSForms.ComboBox Then
' 'ElseIf TypeName(Ctrl) = "ComboBox" Then
' Cells(Ligne, C) = Ctrl
' ElseIf TypeOf Ctrl Is MSForms.CheckBox Then
' 'ElseIf TypeName(Ctrl) = "CheckBox" Then
' Cells(Ligne, C) = IIf(Ctrl, SelectAna, "")
' End If
WsBase.Cells(Ligne, C).Value = IIf(Me.Controls("CheckBox" & C - 3) = True, SelectAna, "")
'WsBase.Cells(Ligne, C).Value = IIf(Me.Controls(WsBase.Cells(1, C)) = True, SelectAna, "")
If Cells(Ligne, C) = "OUI" Then
WsBase.Cells(Ligne, C).Interior.Color = RGB(255, 51, 0)
WsBase.Cells(Ligne, C).Font.Color = RGB(0, 0, 0)
End If
Next C
'Next Ctrl
End Sub