Titre du sujet : Re: Aide pour Userform par myDearFriend! le 04/01/2012 15:34:31
Bonjour Slijack,
Tu trouveras en pièce jointe mon interprétation du problème.
L'ajout d'un contrôle SpinButton me semble un peu plus approprié que le TextBox mis par tes soins.
J'ai donc ajouté/modifié le code VBA suivant (dans le module de code du Userform) :
'*************************************************************************************
'Modification myDearFriend! (www.mDF-XLpages.com) - janvier 2012
Private Sub LbFeuilles_Change()
With LbFeuilles
.List(.ListIndex, 1) = IIf(.Selected(.ListIndex), 1, "")
spbPages.Enabled = .Selected(.ListIndex)
End With
MajCptFeuilles
End Sub
Private Sub spbPages_SpinDown()
With LbFeuilles
.List(.ListIndex, 1) = Application.Max(Val(.List(.ListIndex, 1)) - 1, 1)
End With
MajCptFeuilles
End Sub
Private Sub spbPages_SpinUp()
With LbFeuilles
.List(.ListIndex, 1) = Val(.List(.ListIndex, 1)) + 1
End With
MajCptFeuilles
End Sub
Private Sub MajCptFeuilles()
Dim n As Integer
Dim S As Byte
With LbFeuilles
For S = 0 To .ListCount - 1
If Not IsNull(.List(S, 1)) Then
n = n + Val(.List(S, 1))
End If
Next S
End With
LblNombreFeuilles.Caption = "Nbre de Feuilles: " & n
End Sub
Private Sub CmdWsToutesSelection_Click()
With LbFeuilles
For I = 0 To .ListCount - 1
.ListIndex = I
If Not .Selected(I) Then .Selected(I) = True
Next I
End With
End Sub
Private Sub CmdWsAucuneSelection_Click()
With LbFeuilles
For I = 0 To .ListCount - 1
.ListIndex = I
.Selected(I) = False
Next I
End With
End Sub
Private Sub CmdImprimer_Click()
With Application
.ScreenUpdating = False
For I = 0 To LbFeuilles.ListCount - 1
If LbFeuilles.Selected(I) = True Then
.StatusBar = "Impression: " & LbFeuilles.List(I)
.DisplayAlerts = False
Sheets(LbFeuilles.List(I)).PrintOut Copies:=Val(LbFeuilles.List(I, 1))
.DisplayAlerts = True
End If
Next I
.StatusBar = False
.ScreenUpdating = True
End With
Unload Me
End Sub
En espérant que ça puisse te rendre service.
Cordialement,
|