Re : problemes sur USERFORM
bonjour JPN,
petite question: j'ai adapté mon fichier pour un autre service, mon soucis c'est que j'alimente un listbox via un combobox, le listbox est à selection multiples, je bloque sur comment envoyer les selections dans la feuille commentaire.
Private Sub CommandButton1_Click() ' dans l userform seul 'residence,commentaires et divers peuvent etre modifiés
Dim Résultat As Range
'--- Contrôles
If matricule = "" Then
matricule.SetFocus
Exit Sub
End If
'--- Positionnement dans la base
Set Résultat = Sheets("commentaires").Columns(1).Find(what:=Me.matricule, LookIn:=xlValues)
If Résultat Is Nothing Then
Set Résultat = Sheets("commentaires").Columns(1).Find(what:="", LookIn:=xlValues)
Résultat.Offset(0, 0).Value = matricule
Résultat.Offset(0, 1).Value = choixNom
End If
'--- Transfert Formulaire dans feuille commentaire
Résultat.Offset(0, 2).Value = Application.Proper(Me!ECR1)
Résultat.Offset(0, 3).Value = Application.Proper(Me!AA1)
Résultat.Offset(0, 4).Value = Application.Proper(Me!MSUP1)
Résultat.Offset(0, 5).Value = Application.Proper(Me!TRONC1)
Résultat.Offset(0, 6).Value = Application.Proper(Me!TOTAL1)
Résultat.Offset(0, 7).Value = Application.Proper(Me!PLANCHE1)
Résultat.Offset(0, 8).Value = Application.Proper(Me!PPA1)
Résultat.Offset(0, 9).Value = Application.Proper(Me!EPIC1)
Résultat.Offset(0, 10).Value = Application.Proper(Me!ECR2)
Résultat.Offset(0, 11).Value = Application.Proper(Me!AA2)
Résultat.Offset(0, 12).Value = Application.Proper(Me!MSUP2)
Résultat.Offset(0, 13).Value = Application.Proper(Me!TRONC2)
Résultat.Offset(0, 14).Value = Application.Proper(Me!TOTAL2)
Résultat.Offset(0, 15).Value = Application.Proper(Me!PLANCHE2)
Résultat.Offset(0, 16).Value = Application.Proper(Me!PPA2)
Résultat.Offset(0, 17).Value = Application.Proper(Me!EPIC2)
Résultat.Offset(0, 18).Value = Application.Proper(Me!exemption)
Résultat.Offset(0, 27).Value = Application.Proper(Me!perfgpt)
Résultat.Offset(0, 28).Value = Application.Proper(Me!classgpt)
Résultat.Offset(0, 26).Value = Application.Proper(Me!courlong)
End Sub
Private Sub CommandButton3_Click()
Unload Me
End Sub
Private Sub CommandButton4_Click()
UserForm1.PrintForm
End Sub
Private Sub exemption_Change()
Dim c As Range
choixexemption.Clear
With Sheets("entree")
For Each c In .Range("v1:v" & .Range("v65536").End(xlUp).Row)
If c = exemption Then
choixexemption.AddItem c.Offset(0, 1)
End If
Next c
End With
End Sub
Private Sub Frame2_Click()
End Sub
Private Sub Frame5_Click()
End Sub
Private Sub Image1_Click()
End Sub
''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''
Private Sub UserForm_Initialize()
''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'alimente les listes '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim cell As Range
With Sheets("BD")
For Each cell In .Range("b2:b" & .Range("b65536").End(xlUp).Row)
choixNom.AddItem cell
Next
End With
With Sheets("entree")
For Each cell In .Range("x1:x" & .Range("x65536").End(xlUp).Row)
courlong.AddItem cell
Next
End With
With Sheets("entree")
For Each cell In .Range("x1:x" & .Range("x65536").End(xlUp).Row)
cour.AddItem cell
Next
End With
With Sheets("entree")
For Each cell In .Range("x1:x" & .Range("x65536").End(xlUp).Row)
longcour.AddItem cell
Next
End With
'''''''''''''''''''''''''''''''''
'exemption'
'''''''''''''''''''''''''''''''''
Dim c As Range
Dim data As New Collection
Dim el
With choixexemption
.ColumnCount = 2
.ColumnWidths = "10;0"
.MultiSelect = fmMultiSelectMulti
.ListStyle = fmListStyleOption
End With
With Sheets("entree")
On Error Resume Next
For Each c In .Range("v1:v" & .Range("v65536").End(xlUp).Row)
data.Add c, CStr(c)
Next c
On Error GoTo 0
For Each el In data
exemption.AddItem el
Next el
End With
End Sub
Private Sub ChoixNom_Change() 'alimente l'userform'
Dim Résultat As Range
With Sheets("BD")
age = Format(.Cells(choixNom.ListIndex + 2, 16), "yy") 'le 16 represente la colonne16'
grade = .Cells(choixNom.ListIndex + 2, 4)
matricule = .Cells(choixNom.ListIndex + 2, 1)
prenom = .Cells(choixNom.ListIndex + 2, 3)
service = .Cells(choixNom.ListIndex + 2, 5)
cs = .Cells(choixNom.ListIndex + 2, 7)
datedenaissance = .Cells(choixNom.ListIndex + 2, 8)
depuisle = .Cells(choixNom.ListIndex + 2, 6)
End With
'alimente le textbox residence commentaires et divers
With Sheets("commentaires")
Set Résultat = .Columns(1).Find(what:=Me.matricule, LookIn:=xlValues)
If Résultat Is Nothing Then
ECR1 = ""
AA1 = ""
MSUP1 = ""
TRONC1 = ""
TOTAL1 = ""
PLANCHE1 = ""
PPA1 = ""
EPIC1 = ""
ECR2 = ""
AA2 = ""
MSUP2 = ""
TRONC2 = ""
TOTAL2 = ""
PLANCHE2 = ""
PPA2 = ""
EPIC2 = ""
exemption = ""
ListBox1 = ""
ListBox2 = ""
ListBox3 = ""
perfgpt = ""
perfbrig = ""
perfvet = ""
classgpt = ""
classbrig = ""
classvet = ""
Exit Sub
Else
ECR1 = .Cells(Résultat.Row, 3)
AA1 = .Cells(Résultat.Row, 4)
MSUP1 = .Cells(Résultat.Row, 5)
TRONC1 = .Cells(Résultat.Row, 6)
TOTAL1 = .Cells(Résultat.Row, 7)
PLANCHE1 = .Cells(Résultat.Row, 8)
PPA1 = .Cells(Résultat.Row, 9)
EPIC1 = .Cells(Résultat.Row, 10)
ECR2 = .Cells(Résultat.Row, 11)
AA2 = .Cells(Résultat.Row, 12)
MSUP2 = .Cells(Résultat.Row, 13)
TRONC2 = .Cells(Résultat.Row, 14)
TOTAL2 = .Cells(Résultat.Row, 15)
PLANCHE2 = .Cells(Résultat.Row, 16)
PPA2 = .Cells(Résultat.Row, 17)
EPIC2 = .Cells(Résultat.Row, 18)
exemption = .Cells(Résultat.Row, 19)
courlong = .Cells(Résultat.Row, 26)
cour = .Cells(Résultat.Row, 30)
longcour = .Cells(Résultat.Row, 34)
perfgpt = .Cells(Résultat.Row, 27)
classgpt = .Cells(Résultat.Row, 28)
perfbrig = .Cells(Résultat.Row, 31)
classbrig = .Cells(Résultat.Row, 32)
perfvet = .Cells(Résultat.Row, 35)
classvet = .Cells(Résultat.Row, 36)
End If
End With
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'affichage photo
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Private Sub matricule_change()
' Dim Photo As String
' On Error GoTo Fin 'si erreur aller à fin
' Photo = matricule.Value
' Image1.Picture = LoadPicture("T:\Partage\Photos Vidéos\Photos\photos identites\" & Photo & ".jpg") ' chemin d acces (partage) ("C:\Users\nicolas\Pictures\" & Photo & ".jpg")
'image1.picture= loadpicture("T:\bspp.fr\travail\27eme\genn\bureau soa\situation tdop 27eme\situ\reserve situ\pas touche\
' Exit Sub ' ici on sort si pas d'erreur
'Fin: 'ici c'est l'image par défaut qui s'affiche en cas d'erreur
' Image1.Picture = LoadPicture("T:\Partage\Photos Vidéos\Photos\photos identites\image_defaut.jpg") ' idem ci dessus
' Err.Clear ' Efface les champs d'erreur
'End Sub