Sub Effacer_Tout()
Dim ligne As Long 'Ligne de BD
Dim Col As Long 'Colonne
Dim obj As Control
'Si une sélection de chambre a étée faite
If cbChambres.ListIndex > -1 Then
'Récupération du numéro de ligne dans la feuille
ligne = 6 + cbChambres.ListIndex
Sheets("BD").Range("F" & ligne & ":DK" & ligne).ClearContents
For Each obj In Me.Controls
If Left(obj.Name, 2) = "lb" Then
obj.Caption = ""
Else
If TypeName(obj) = "ComboBox" Or TypeName(obj) = "TextBox" Then obj.Text = ""
End If
Next
End If
End Sub
dim Col as long
ligne = 6 + cbChambres.ListIndex
'Pour les combos
For Col=11 to 115
Sheets("BD").cells(ligne, col)=me.controls("cbx" & i).value
Next
En complément de la proposition de HascoLionel,
conseil: renomme tes combos avec pour racine de nom "cbx" et complément le numéro de colonne. ex cbx11
A+
Pour trouver ce type d'erreur il faut utiliser la touche F8 et poser les points d'arrêts au fur et à mesure du contrôle du code.Bonjour Hasco, JP14, le fil, le forum,
J'ai tenté d'adapter, mais j'ai commis une erreur...
Vos yeux experts la trouveront certainment.
Merci pour votre patience et votre dévouement.
A++
Lio
Private Sub ecrirelabel(£ligne1 As Long, £nomfeuille1 As String)
' Nom des label
' Label & numéro d'ordre= numéro colonne
Dim £Ctrl As Control
Dim £coln As Long
Dim £data1 As String
With Sheets(£nomfeuille1)
For Each £Ctrl In Me.Controls
If TypeName(£Ctrl) = "Label" Then
£data1 = Replace(£Ctrl.Name, "Label", "")
coln = Val(£data1)
Me.Controls(£Ctrl.Name).Caption = .Cells(£ligne1, coln)
End If
Next £Ctrl
End With
End Sub
.....
' Pour chaque Combobox, attribuer la liste des AVERSIONS
For Inc = [COLOR=Blue][B]31 To 41[/B][/COLOR]
Call MaJCombo(Me("cbxt" & Inc))
Next Inc
' Récupérer la liste des PREFERENCES sans ESPACES NI DOUBLONS et la TRIER
' Appeler la procédure avec le nom de la plage
Call CreationListe("Preferences")
' Pour chaque Combobox, attribuer la liste des PREFERENCES
For Inc = [B][COLOR=Blue]42 To 49[/COLOR][/B]
Call MaJCombo(Me("cbxp" & Inc))
Next Inc
Private Sub BtnSave_Click()
Dim Col As Long
'Dim I As Variant
ligne = 6 + cbChambres.ListIndex
'Pour les combos
For Col = 11 To 19
Sheets("BD").Cells(ligne, Col) = Me.Controls("cbx" & [COLOR=Blue][B]Col[/B][/COLOR]).Value
Next
For Col = 20 To 30
Sheets("BD").Cells(ligne, Col) = Me.Controls("cbx" & [B][COLOR=Blue]Col[/COLOR][/B]).Value
Next
For Col = 50 To 115
Sheets("BD").Cells(ligne, Col) = Me.Controls("cbx" & [B][COLOR=Blue]Col[/COLOR][/B]).Value
Next
For Col = 31 To 41
Sheets("BD").Cells(ligne, Col) = Me.Controls("cbxt" & [B][COLOR=Blue]Col[/COLOR][/B]).Value
Next
For Col = 42 To 49
Sheets("BD").Cells(ligne, Col) = Me.Controls("cbxp" & [B][COLOR=Blue]Col[/COLOR][/B]).Value
Next
End Sub
Merci à vous tous"je comprends vite quand on m'explique longntemps"