ISsue in Generating series

adeel1
3StarLounger
Posts: 264
Joined: 04 Oct 2017, 15:47

ISsue in Generating series

Post by adeel1 »

Hello All

I want to make series of 18 digit (can be vary) I can understand addition in second row making it hexadecimal how I can manage it!

in second input box if i put 333440000000000001 and in first 20 than generate series!

Code: Select all

Sub series()

Range("b:d").Clear
'Columns(2).NumberFormat = "@"
f = InputBox("please enter total series required")
ff = InputBox("enter start series num")
'fff = InputBox("enter start series num")
For i = 1 To f
c = (Cells(i, 1).Row - 1) Mod 9
'Cells(i + 1, 2).NumberFormat = "@"
Cells(i + 1, 2) = "'" & ff + h & c
h = h + 1
Cells(i + 1, 4).Value = Len(Cells(i + 1, 2).Value)
Next i

End Sub
You do not have the required permissions to view the files attached to this post.

User avatar
HansV
Administrator
Posts: 78398
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: ISsue in Generating series

Post by HansV »

I don't understand the question. Can you try to explain it more clearly?
Best wishes,
Hans

adeel1
3StarLounger
Posts: 264
Joined: 04 Oct 2017, 15:47

Re: ISsue in Generating series

Post by adeel1 »

if you run the code two input box will appear first will total number of series required and other to start of series num if i put this 333440000000000001 in second box then below should be result in col b!

333440000000000001
333440000000000002
333440000000000003
333440000000000004
333440000000000005
333440000000000006
333440000000000007
333440000000000008
333440000000000009
333440000000000010
333440000000000011
333440000000000012
333440000000000013
333440000000000014
333440000000000015

ignore this part in code, it is just concat to fill data
c = (Cells(i, 1).Row - 1) Mod 9
Adeel

User avatar
HansV
Administrator
Posts: 78398
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: ISsue in Generating series

Post by HansV »

Excel cannot handle 18 significant digits, so we have to use a trick.

Code: Select all

Sub series()
    Dim f As Long
    Dim ff As String
    Dim i As Long
    Dim n As Long
    Dim s As String
    Dim k As Currency
    Dim m As Long
    f = InputBox("please enter total series required")
    ff = InputBox("enter start series num")
    n = Len(ff)
    If n > 26 Then
        MsgBox "Start number is too long!", vbExclamation
        Exit Sub
    End If
    If n > 13 Then
        s = Left(ff, 13)
        k = Mid(ff, 14)
        m = n - 13
    Else
        k = ff
        m = n
    End If
    Application.ScreenUpdating = False
    Range("B:D").Clear
    For i = 1 To f
        Cells(i + 1, 2) = "'" & s & Format(k + i - 1, String(m, "0"))
        Cells(i + 1, 4).Value = Len(Cells(i + 1, 2).Value)
    Next i
    Application.ScreenUpdating = True
End Sub
Please test thoroughly.
Best wishes,
Hans

adeel1
3StarLounger
Posts: 264
Joined: 04 Oct 2017, 15:47

Re: ISsue in Generating series

Post by adeel1 »

thnx a lot :thankyou: , I will focus on this tomorrow! I will be back if need to understand something! :thankyou: :fanfare:

Adeel