Const tRollStr As String = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" Private Function GetNext(ByVal Code As String) As String UpdateCode Code, Len(Code) GetNext = Code End Function Private Function UpdateCode(ByRef Code As String, ByVal Index As Long) Dim i As Long If Index = 0 Then Code = Mid(tRollStr, 2, 1) & Code Else i = InStr(tRollStr, Mid(Code, Index, 1)) i IIf(i Len(tRollStr), 1, i + 1) Mid(Code, Index, 1) = Mid(tRollStr, i, 1) If i = 1 Then UpdateCode Code, Index - 1 End If End If End Function Sub Incremente() Dim nbLignes As Long Dim l As Long nbLignes = CLng(InputBox("Nombre de lignes à ajouter :")) For l = ActiveCell.Row To ActiveCell.Row + nbLignes - 1 Cells(l + 1, ActiveCell.Column).Value = GetNext(Cells(l, ActiveCell.Column).Value) Next End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question