Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questiondébutante en visual basic (très très débutante)
Option Explicit
Private Const les_donnees As String = "Donnees"
Private Const NOM As String = "A"
Private Const VILLE As String = "B"
Private Sub ComboBox1_Change()
If Not encours Is Nothing Then encours.Text = ComboBox1.Text
ActiveControl.ZOrder
End Sub
Private Sub ComboBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
validation
End Sub
Private Sub ComboBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 46 And Shift = 2 Then suppression
End Sub
Private Sub CommandButton1_Click()
MsgBox "contenus des deux champs : " & vbCrLf & _
"nom =======>> " & TB_noms.Text & vbCrLf & _
"ville =====>>" & TB_villes.Text & vbCrLf & vbCrLf & _
"que vous pouvez donc enregistrer là où vous le souhaitez."
End Sub
Private Sub TB_noms_Enter()
traitons ActiveControl, les_donnees, NOM
End Sub
Private Sub TB_villes_Enter()
traitons ActiveControl, les_donnees, VILLE
End Sub
Private Sub UserForm_Initialize()
Set CB = ComboBox1
Set Fant = fantome
With Worksheets(les_donnees)
.Range("A1").Value = "NOMS"
.Range("B1").Value = "VILLES"
End With
placons
End Sub
Option Explicit
Public encours As Object, CB As Object, Fant As Object
Private F As String, c As String
Public Sub traitons(TB As Object, feuille As String, colonne As String)
Dim derlig As Long
F = feuille
c = colonne
With TB
derlig = Worksheets(F).Range(c & Rows.Count).End(xlUp).Row
.Tag = F & "!" & c & "2:" & c & derlig
End With
With CB
.Move TB.Left, TB.Top, TB.Width, TB.Height
.RowSource = TB.Tag
.Visible = True
.Text = TB.Text
.ZOrder
.SetFocus
End With
Set encours = TB
DoEvents
End Sub
Public Sub placons()
CB.Visible = False
CB.MatchEntry = fmMatchEntryComplete
CB.ZOrder
Fant.Move -10, -10, 3, 3
Fant.SetFocus
End Sub
Public Sub suppression()
Dim rang As Long, derlig As Long
With CB
If .ListIndex = -1 Then Exit Sub
rang = .ListIndex + 2
If MsgBox("Etes-vous certain(e) de vouloir supprimer " & _
.Text & " de la liste des " & Worksheets(F).Cells(1, c).Value & _
" répertorié(e)s ?", vbYesNo) <> vbYes Then Exit Sub
.Text = ""
derlig = Worksheets(F).Cells(Rows.Count, c).End(xlUp).Row
If rang = derlig Then
Worksheets(F).Cells(rang, c).Value = ""
Else
Worksheets(F).Cells(rang, c).Value = Worksheets(F).Cells(derlig, c).Value
Worksheets(F).Cells(derlig, c).Value = ""
End If
.Text = ""
End With
End Sub
Public Sub validation()
Dim derlig As Long
With CB
If Not encours Is Nothing Then
encours.Text = .Text
If .ListIndex = -1 And .Text <> "" And Not encours Is Nothing Then
If MsgBox("Souhaitez-vous ajouter " & .Text & " à la liste des " & _
Worksheets(F).Cells(1, c).Value & " répertorié(e)s ?", vbYesNo) = vbYes Then
derlig = Worksheets(F).Cells(Rows.Count, c).End(xlUp).Row + 1
Worksheets(F).Cells(derlig, c) = .Text
End If
End If
DoEvents
End If
End With
Set encours = Nothing
End Sub
userform1.show
Une autre question: il faut que je fasse la macro pour lancer le formulaire (TB_noms...) c'est bien ça ?
développeurséventuellement intéressés.
Depuis où tu veux : lance :
userform1.show
--