Problème formulaire recupération valeur VBA

nina71287

XLDnaute Occasionnel
Bonsoir à tous,

J'aurais besoin d'aide sur mon code qui ne marche pas svp. Le voici:

Dim mois As String
Dim sem As Integer
Dim nbligne As Integer
Dim nbligne1 As Integer
Dim strdate As String
Dim col As Integer
Dim colonne As String
Private Sub UserForm_Initialize()
Me.ComboBox1.AddItem ("Janvier")
Me.ComboBox1.AddItem ("Février")
Me.ComboBox1.AddItem ("Mars")
Me.ComboBox1.AddItem ("Avril")
Me.ComboBox1.AddItem ("Mai")
Me.ComboBox1.AddItem ("Juin")
Me.ComboBox1.AddItem ("Juillet")
Me.ComboBox1.AddItem ("Août")
Me.ComboBox1.AddItem ("Septembre")
Me.ComboBox1.AddItem ("Octobre")
Me.ComboBox1.AddItem ("Novembre")
Me.ComboBox1.AddItem ("Décembre")
End Sub

Private Sub ok_Click()
Hide
mois = Me.ComboBox1.Value
MsgBox (mois)
End Sub

Private Sub annuler_Click()
Hide
End Sub

Sub semaine()
sem = InputBox("indiquez la semaine")
End Sub

Sub recherche_date()
strdate = Application.InputBox(Prompt:="Entrer une date", Title:="DATE ", Default:=Format(Date - 1, "Short Date"), Type:=1)
'Cancelled
If strdate = "False" Then Exit Sub
strdate = Format(strdate, "Short Date")
On Error Resume Next
Set rCell = Cells.Find(What:=CDate(strdate), After:=Range("B1"), LookIn:=xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
On Error GoTo 0
If rCell Is Nothing Then
lReply = MsgBox("La date ne peut pas être trouvée. Essayer de nouveau", vbYesNo)
If lReply = vbYes Then Run "recherche_date":
End If
nbligne = rCell.Row
d = Cells(nbligne, 2).Value
nbcol = rCell.Offset(0, 2)
recherche_jour
Application.ScreenUpdating = False
End Sub
Sub recherche_jour()
j = Weekday(d)
If j = 1 Then
j = "Dimanche"
ElseIf j = 2 Then
j = "Lundi"
ElseIf j = 3 Then
j = "Mardi"
ElseIf j = 4 Then
j = "Mercredi"
ElseIf j = 5 Then
j = "Jeudi"
ElseIf j = 6 Then
j = "Vendredi"
ElseIf j = 7 Then
j = "Samedi"
Else
MsgBox ("la date n'est pas valide")
End If
End Sub
Sub AfficheListeDeroulante()
UserForm1.Show
End Sub
Sub tableau_bord()
AfficheListeDeroulante
aujourdhui = Date
Windows("Report support distribution_2009.xlsm").Activate
Dim c As Range
With Worksheets("synthèse").Range("a1:z4")
Set c = .Find("Total", LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
col = c.Column
End If
End With
If Cells(3, col - 1).Value = mois Then
MsgBox ("Les résultats de " & mois & " vont etre mis à jour")
Else
colonne = Mid(firstAddress, 2, 1)
MsgBox ("Les résultats du mois d' " & mois & " vont être mis à jour")
Columns(colonne & ":" & colonne).Select
'insere une nouvelle ligne
Sheets("synthèse").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove

End If


Le formulaire marche j'arrive à récupérer ma valeur sélectionnée dans ma liste (j'ai vérifiée à l'aide du msgbox) mais aprés quand je veux réutiliser ma variable mois dans un autre sous programme elle est vide :mad:. Quelqu'un peut il m'expliquer? merci d'avance pour votre aide.

Bonne soirée :)
 

Statistiques des forums

Discussions
311 724
Messages
2 081 936
Membres
101 844
dernier inscrit
pktla