+ Reply to Thread
Results 1 to 2 of 2

sequential number breaks

Hybrid View

  1. #1
    Cyberwolf
    Guest

    sequential number breaks

    I am trying to write code that will look throught a spreadsheet and find a
    break in a sequential field. i.e. , 2, 3, 5

    Once the break is fouind I would place a blank line between these and
    continue until I reach the end of the file

    I know how to place the blank line and know how to find the end of the file,
    I just can't figure the code for finding the breaks in the numbers.

  2. #2
    Ian
    Guest

    Re: sequential number breaks

    This will only work for sequences as you quoted ie 1,2,3,5. It would need
    modification for 2,4,8,10 etc.
    Change the rowz range to suit your data. The start row needs to be the
    second row of data as it compares to the previous row.

    Sub findsequencebreak()
    diff = 1
    For rowz = 2 To 12
    Cells(rowz, 1).Select
    If Cells(rowz, 1) <> Cells(rowz - diff, 1) + diff Then
    Cells(rowz, 1).EntireRow.Insert
    diff = 2
    Else
    diff = 1
    End If
    Next rowz
    End Sub


    --
    Ian
    --
    "Cyberwolf" <[email protected]> wrote in message
    news:[email protected]...
    >I am trying to write code that will look throught a spreadsheet and find a
    > break in a sequential field. i.e. , 2, 3, 5
    >
    > Once the break is fouind I would place a blank line between these and
    > continue until I reach the end of the file
    >
    > I know how to place the blank line and know how to find the end of the
    > file,
    > I just can't figure the code for finding the breaks in the numbers.




+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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