XL 2013 incrémenter une série en fonction cellule

chindou

XLDnaute Occasionnel
Bonjour le forum

Je souhaite incrémenter automatiquement à l’aide VBA, une série de données en fonction d’une valeur dans une cellule
(La valeur de cette cellule est la dernière valeur d’incrémentation)
Incrémenter :
Le contenu de la cellule B3 en fonction de B1
Le contenu de la cellule C3 en fonction de C1
Le contenu de la cellule D3 en fonction de D1
Le contenu de la cellule E3 en fonction de E1

Les valeurs de B1 ; C1 ; D1 et E1 sont modifiable par un UserForm (Userform2 dans fichier exemple)

Je vous joins un fichier exemple :
Merci d'avance
Cordialement
 

Pièces jointes

  • Incrémentation.xlsm
    26.9 KB · Affichages: 8
Solution
Bonsoir chindou, Phil69970,

Voyez le fichier joint et les codes des 2 UserForms, UserForm1 :
VB:
Private Sub CommandButton1_Click()
Unload Me
End Sub

Private Sub UserForm_Initialize()
Dim col%
With Feuil1
    For col = 2 To 5
        Me("ComboBox" & col - 1).List = .Cells(3, col).Resize(.Cells(1, col), 2).Value 'au moins 2 éléments
    Next
End With
End Sub
Et UseForm2 :
VB:
Private Sub CommandButton2_Click()
Unload Me
End Sub

Private Sub CommandButton1_Click() 'OK
Dim col%
Application.ScreenUpdating = False
With Feuil1
    For col = 2 To 5
        .Cells(1, col) = Abs(Int(Val(Me("TextBox" & col - 1))))
        .Cells(3, col).Resize(.Rows.Count - 2).Delete xlUp 'RAZ
        If .Cells(1, col) Then
            .Cells(1, col).Copy...

job75

XLDnaute Barbatruc
Bonsoir chindou, Phil69970,

Voyez le fichier joint et les codes des 2 UserForms, UserForm1 :
VB:
Private Sub CommandButton1_Click()
Unload Me
End Sub

Private Sub UserForm_Initialize()
Dim col%
With Feuil1
    For col = 2 To 5
        Me("ComboBox" & col - 1).List = .Cells(3, col).Resize(.Cells(1, col), 2).Value 'au moins 2 éléments
    Next
End With
End Sub
Et UseForm2 :
VB:
Private Sub CommandButton2_Click()
Unload Me
End Sub

Private Sub CommandButton1_Click() 'OK
Dim col%
Application.ScreenUpdating = False
With Feuil1
    For col = 2 To 5
        .Cells(1, col) = Abs(Int(Val(Me("TextBox" & col - 1))))
        .Cells(3, col).Resize(.Rows.Count - 2).Delete xlUp 'RAZ
        If .Cells(1, col) Then
            .Cells(1, col).Copy .Cells(3, col) 'pour les formats
            .Cells(3, col) = 8 - col & "e_1"
            If .Cells(1, col) > 1 Then .Cells(3, col).AutoFill .Cells(3, col).Resize(.Cells(1, col))
        End If
    Next
End With
Unload Me
End Sub

Private Sub UserForm_Initialize()
Dim col%
For col = 2 To 5
    Me("TextBox" & col - 1).Value = Feuil1.Cells(1, col)
Next
End Sub
A+
 

Pièces jointes

  • Incrémentation(1).xlsm
    28.1 KB · Affichages: 1

chindou

XLDnaute Occasionnel
Bonsoir phil69970

non non ce n'est pas ça, excuse-moi Phil69970 sincèrement je n'ai pas vu ta réponse
car j’ai exploré la réponse via l’option notification qui ma montrer qu’une seul réponse c’était de job75
on ouvrant maintenant le forum je remarque une autre notification c’était la tienne alors je n’ai pas tardé à te répondre

Merci bien Phil69970
 

Discussions similaires

Statistiques des forums

Discussions
311 720
Messages
2 081 926
Membres
101 842
dernier inscrit
seb0390