X
xa
Guest
Bonjour,
Dans mon code ci-dessous il n'y a que le N° du combobox qui varie, le code ci dessous ne fonctionne pas mais auriez vous une idée?
Dim i As Integer
Dim n As Variant
If Label34.Visible = True Then
n=36
end if
If Label36.Visible = True Then
n=42
end if
If Me.ComboBox(n).Value = "" Then GoTo erreur
Sheets("Donnees").Select
Columns("A:A").Select
Set marech = Selection.Find(What:=ComboBox(n), After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False)
If Not marech Is Nothing Then
'Rien ne se passe
Else
i = 1
Do While Not IsEmpty(Sheets("Donnees").Cells(i, 1))
i = i + 1
Loop
With Sheets("Donnees")
.Cells(i, 1) = Me.ComboBox(n).Value
End With
Columns("A:A").Select
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Me.ComboBox(n).Value = ""
i = 2
Do While Not IsEmpty(Sheets("Donnees").Cells(i, 1))
i = i + 1
Loop
Me.ComboBox(n).RowSource = "Donnees!A1:A" & i - 1
Exit Sub
erreur:
MsgBox "Veuillez renseigner tous les champs!", vbExclamation, " "
End If
End If
Merci d'avance
Aurevoir
Dans mon code ci-dessous il n'y a que le N° du combobox qui varie, le code ci dessous ne fonctionne pas mais auriez vous une idée?
Dim i As Integer
Dim n As Variant
If Label34.Visible = True Then
n=36
end if
If Label36.Visible = True Then
n=42
end if
If Me.ComboBox(n).Value = "" Then GoTo erreur
Sheets("Donnees").Select
Columns("A:A").Select
Set marech = Selection.Find(What:=ComboBox(n), After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False)
If Not marech Is Nothing Then
'Rien ne se passe
Else
i = 1
Do While Not IsEmpty(Sheets("Donnees").Cells(i, 1))
i = i + 1
Loop
With Sheets("Donnees")
.Cells(i, 1) = Me.ComboBox(n).Value
End With
Columns("A:A").Select
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Me.ComboBox(n).Value = ""
i = 2
Do While Not IsEmpty(Sheets("Donnees").Cells(i, 1))
i = i + 1
Loop
Me.ComboBox(n).RowSource = "Donnees!A1:A" & i - 1
Exit Sub
erreur:
MsgBox "Veuillez renseigner tous les champs!", vbExclamation, " "
End If
End If
Merci d'avance
Aurevoir