The code below may do what you want. It will scan the numbers in column A of
Sheet1 and put the start and end number of each series of sequential numbers
out to Sheet2, with the starting number of the block in Sheet2 column A and
ending number of each block in Sheet2 column B. Change the lines of code
marked with '<<< to your specific needs.
Sub LookAtLists()
Dim StartRow As Long ' data begins in this row
Dim EndRow As Long ' data ends in this row (calculated)
Dim Temp As Long
Dim RowNdx As Long
Dim Dest As Range ' results are written starting in this cell
Dim DataColumn As String ' data is in this column
Dim WS As Worksheet ' data resides on this worksheet
Dim SaveStart As Long
StartRow = 1 '<<< CHANGE
DataColumn = "A" '<<< CHANGE
Set WS = Worksheets("Sheet1") '<<< CHANGE
Set Dest = Worksheets("Sheet2").Range("A1") '<<< CHANGE
With WS ' note the leading periods in the lines of code below
EndRow = .Cells(.Rows.Count, DataColumn).End(xlUp).Row
SaveStart = .Cells(StartRow, DataColumn)
For RowNdx = StartRow + 1 To EndRow
If .Cells(RowNdx, DataColumn) + 1 <> .Cells(RowNdx + 1, DataColumn)
Then
Dest(1, 1) = SaveStart
Dest(1, 2) = .Cells(RowNdx, DataColumn).Value
SaveStart = .Cells(RowNdx + 1, DataColumn).Value
Set Dest = Dest(2, 1)
End If
Next RowNdx
End With
End Sub
--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)Sub LookAtLists()
"Quco" <(E-Mail Removed)> wrote in message
news:9938BC85-513A-41B1-995C-(E-Mail Removed)...
> Hi, I have a LOOOONNNG list of 5-digit numbers in a spreadsheet. They are
> all
> listed in the A column. We only need to report the unknown ranges for this
> numbers, not the actual numbers. How can I do that?
>
> Doing this manually after sorting the data is taking us forever.
>
> Here's an example, I cut and paste a super-small portion of the sorted
> data
> here:
>
> 41222
> 41223
> 41224
> 41225
> 41226
> 41227
> 41762
> 41763
> 41764
> 41765
> 41766
> 41767
> 41768
> 41769
> 41770
> 41771
> 41772
> 41773
> 41774
> 41775
> 41776
> 41777
> 42302
> 42303
> 42304
> 42305
> 42306
> 42307
> 42308
> 42309
> 42310
> 42311
> 42312
> 42313
> 42314
> 42315
> 42316
> 42830
> 42831
> 42832
> 42833
> 42834
> 42835
> 42836
> 42837
> 42838
> 42839
> 42842
> 42843
> 42844
> 42845
> 42846
> 42847
> 42848
>
> And this is what we need:
>
> Range 1: 41222-41227
> Range 2: 41762-41777
> Range 3: 42302-42316
> Range 4: 42830-42848
> etc...
>
> Any suggestions?
>