+ Reply to Thread
Results 1 to 11 of 11

Code to create numbers in sequence

Hybrid View

  1. #1
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,678

    Re: Code to create numbers in sequence

    Also mine corrected:
    Sub test()
    Dim i As Long, j As Long, k As Long, current As Long, cell As Range, prefix As String
    Application.ScreenUpdating = False
    For k = Cells(Rows.Count, "A").End(xlUp).Row To 1 Step -1
      Set cell = Cells(k, 1)
      current = Val(IIf(InStr(cell, "-"), Right(cell, Len(cell) - InStrRev(cell, "-")), cell))
      prefix = Replace(cell, current, "")
      j = Val(cell.Offset(0, 1))
      If j > 0 Then
        cell.Offset(1, 0).Resize(j, 1).EntireRow.Insert
        For i = 1 To j
          current = current + 1
          Cells(k + j, 1) = IIf(Len(prefix), prefix & current, current)
        Next i
      End If
    Next k
    End Sub
    Slower one, but could be (who knows ) a bit easier to understand
    Attached Files Attached Files
    Best Regards,

    Kaper

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Create 19rows Add numbers in sequence excel/access2007
    By accessobsess in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-10-2013, 12:26 PM
  2. [SOLVED] Macro to create new sheets with numbers in sequence
    By canyflyer in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 08-21-2013, 07:11 PM
  3. [SOLVED] Creating a sequence based on numbers in one column and adding "01,02..." to a new sequence
    By JCR1968 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-05-2013, 08:06 AM
  4. To generate numbers in sequence using vba code
    By Sriram Anand in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-01-2012, 12:35 PM
  5. Replies: 6
    Last Post: 08-02-2006, 11:40 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1