Incrementation

Bonjour a tous

J'ai besoin de votre aide.

J'ai dans mon fichier une macro qui permet d’incrémenter a partir de 4000 par pas de 2 jusque la tous va bien.

j'ai dupliquer cette macro pour avoir un deuxième bouton pour incrémenter a partir de 5000.

le problème : si je commence par l’incrément 4000 la deuxième macro n’incrémente pas avec les 5000.

Je sais pas si je suis clair dans l'explication ?

Je joint un fichier

Merci d'avance

bonne soirée

Salut Netparty,

une solution sans se casser la tête...

Tu caches les valeurs courantes de chaque série derrière tes boutons!

Tu suis avec une SUB commune aux deux...

Sub User(ByVal iIdx%)
'
Dim iRow%, iCol%, iNum%
'
With Worksheets("UTILISATEURS")
    If WorksheetFunction.CountA(.Range("A1:A" & .Range("A" & Rows.Count).End(xlUp).Row)) < .Range("A" & Rows.Count).End(xlUp).Row Then _
        .Range("A:A").SpecialCells(xlCellTypeBlanks).EntireRow.Delete shift:=xlUp
    iRow = .Range("A" & Rows.Count).End(xlUp).Row + 1
    iCol = IIf(iIdx = 1, 3, 4)
    .Cells(1, iCol) = .Cells(1, iCol) + 2
    iNum = .Cells(1, iCol)
    .Cells(iRow, 1).Value = iNum
    .Cells(iRow, 2).Value = Date
    .Cells(iRow, 3).Value = Environ("USERNAME")
    .Cells(iRow, 4).Select
End With
'
End Sub

A+

9netparty.xlsm (20.42 Ko)

Bonsoir, Salut curulis57,

Une macro commune aussi à tester. A affecter pour les 2 boutons de commande.

Sub increment()
    nombre = Right(ActiveSheet.Shapes(Application.Caller).TextFrame.Characters.Text, 4) * 1
    derLig = Range("A" & Rows.Count).End(xlUp).Row
    nb = WorksheetFunction.CountIfs(Columns(1), ">=" & nombre, Columns(1), "<" & nombre + 1000)
    Range("A" & derLig + 1) = nombre + 2 * nb
    Range("B" & derLig + 1) = Date
    Range("C" & derLig + 1) = Environ("USERNAME")
End Sub

Merci pour votre aide

Bonne soirée

Rechercher des sujets similaires à "incrementation"