bonjour je voudrais savoir faire un remplissage automatique dans un userform suite à une liste deroulante predefinie dans l'userform j'ai ecrit un vba mais je n'arrive pas à faire remplir les zones label de l'userform apres avoir choisi la reference dans mon menu deroulant de l'userform ?
voici mon vba pour l'userform :
Option Explicit
Dim VarSelectedArticle As Integer
Private Sub frmfacturation_Initialize()
Sheets("Facture").Activate
Dim VarDerLigne As Integer
Dim VarPlageList As String
VarDerLigne = Sheets("travail").Range("c65536").End(xlUp).Row
VarPlageList = Sheets("travail").Range("c3:c" & VarDerLigne).Address
listbox1.RowSource = "travail!" & VarPlageList
End Sub
Private Sub ListBox1_Click()
VarSelectedArticle = frmfacturation.listbox1.ListIndex + 2
listbox1 = ""
Labeltype = ""
Labellong = ""
Labeldiam = ""
Labelcube = ""
Labelquart = ""
Labelprix = ""
Labeltotal = ""
listbox1.SetFocus
End Sub
Private Sub cmdsuite_click()
Dim VarDerL As Integer
VarDerL = Sheets("Facture").Range("a51").End(xlUp).Row + 1
If VarDerL = 51 Then
MsgBox "Vous êtes arrivé à la dernière ligne de cette facture", vbCritical, "---------> Fin de la Facture <---------"
Exit Sub
End If
With Sheets("Facture")
.Range("a" & VarDerL) = listbox1.Text
.Range("b" & VarDerL) = lblLabeltype
.Range("c" & VarDerL) = lblLabellong
.Range("d" & VarDerL) = lblLabeldiam
.Range("e" & VarDerL) = lblLabelcube
.Range("f" & VarDerL) = lblLabelquart
.Range("g" & VarDerL) = lblLabelprix
.Range("h" & VarDerL) = lblLabeltotal
End With
End Sub
Private Sub cmdfermer_click()
frmfacturation.Hide
End Sub
Private Sub cmdok_click()
Dim montant As Currency
Dim VarDerLi As Integer
VarDerLi = Sheets("Facture").Range("a51").End(xlUp).Row + 1
montant = Sheets("Facture").Range("h52")
If montant = 0 Then
MsgBox "Vous n'avez entré aucun article dans la facture ! " _
& vbCrLf & "Vous devez avoir au moins 1 article pour procéder à la facturation", _
vbCritical, "Facture non valide"
Exit Sub
End If
End Sub
Private Sub UserForm_Click()
End Sub
je ne peux pas mettre en piece jointe mon tableau car il est beaucoup trop volumineux et du coup meme compresser il ne passe pas donc en attendant qe je reduise mon fichier je vous laisse regarder mon vba pour voir pourquoi ça ne marche pas
merci
voici mon vba pour l'userform :
Option Explicit
Dim VarSelectedArticle As Integer
Private Sub frmfacturation_Initialize()
Sheets("Facture").Activate
Dim VarDerLigne As Integer
Dim VarPlageList As String
VarDerLigne = Sheets("travail").Range("c65536").End(xlUp).Row
VarPlageList = Sheets("travail").Range("c3:c" & VarDerLigne).Address
listbox1.RowSource = "travail!" & VarPlageList
End Sub
Private Sub ListBox1_Click()
VarSelectedArticle = frmfacturation.listbox1.ListIndex + 2
listbox1 = ""
Labeltype = ""
Labellong = ""
Labeldiam = ""
Labelcube = ""
Labelquart = ""
Labelprix = ""
Labeltotal = ""
listbox1.SetFocus
End Sub
Private Sub cmdsuite_click()
Dim VarDerL As Integer
VarDerL = Sheets("Facture").Range("a51").End(xlUp).Row + 1
If VarDerL = 51 Then
MsgBox "Vous êtes arrivé à la dernière ligne de cette facture", vbCritical, "---------> Fin de la Facture <---------"
Exit Sub
End If
With Sheets("Facture")
.Range("a" & VarDerL) = listbox1.Text
.Range("b" & VarDerL) = lblLabeltype
.Range("c" & VarDerL) = lblLabellong
.Range("d" & VarDerL) = lblLabeldiam
.Range("e" & VarDerL) = lblLabelcube
.Range("f" & VarDerL) = lblLabelquart
.Range("g" & VarDerL) = lblLabelprix
.Range("h" & VarDerL) = lblLabeltotal
End With
End Sub
Private Sub cmdfermer_click()
frmfacturation.Hide
End Sub
Private Sub cmdok_click()
Dim montant As Currency
Dim VarDerLi As Integer
VarDerLi = Sheets("Facture").Range("a51").End(xlUp).Row + 1
montant = Sheets("Facture").Range("h52")
If montant = 0 Then
MsgBox "Vous n'avez entré aucun article dans la facture ! " _
& vbCrLf & "Vous devez avoir au moins 1 article pour procéder à la facturation", _
vbCritical, "Facture non valide"
Exit Sub
End If
End Sub
Private Sub UserForm_Click()
End Sub
je ne peux pas mettre en piece jointe mon tableau car il est beaucoup trop volumineux et du coup meme compresser il ne passe pas donc en attendant qe je reduise mon fichier je vous laisse regarder mon vba pour voir pourquoi ça ne marche pas
merci