Probleme passage de valeur variable de inputform à macro (variable declarée dans macro)
Bonjour,
J'ai un probleme pour utiliser dans un inputform une variable appelée dans une macro.
La valeur que j'ai donnée à la variable annee, mois et Gas n'est pas reconnu dans ma macro :(.
Le code de la marco appelant l'inputform est :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
Sub Majlivraison()
Dim mois As Single
Dim annee As Single
Dim Gas As String
Dim icol As Integer 'Compteur de ligne
Dim LastLig As Long
Dim LastLig2 As Long
Dim LastLig3 As Long
Dim sh As Worksheet
Dim sh2 As Worksheet
UserForm1.Show
Set sh = Worksheets("Base")
Set sh2 = Worksheets("2011 livraison")
LastLig = Worksheets("2011 livraison").Cells(Worksheets("2011 livraison").Rows.Count, "A").End(xlUp).Row
icol = 2
MsgBox "valeur M " & mois & " et A " & annee & " et icol" & icol, vbOKOnly + vbInformation
'je coupe sinon c'est trop long je passe directment a la fin du code
Unload UserForm1
End Sub |
Voici le code de l'inputform (inputform1)
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
Private Sub ComboBox1_Change()
ComboBox1.ColumnCount = 1
ComboBox1.List() = Array("Oui", "Non")
Gas = ComboBox1
End Sub
Private Sub CommandButton2_Click()
MsgBox "valeur M " & mois & " et A " & annee
UserForm1.Hide
End Sub
Private Sub TextBox1_Change()
mois = TextBox1.Value
End Sub
Private Sub TextBox2_Change()
annee = TextBox2.Value
End Sub
Private Sub UserForm_Initialize()
TextBox1 = Month(Now) - 1
TextBox2 = Year(Now)
ComboBox1 = "Non"
mois = TextBox1.Value
annee = TextBox2.Value
End Sub |
J'ai fait avec des Msgbox mais les valeurs des variables annee et mois sont vide que ce soit dans le userform ou dans la macro....
Please help.