View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
carlo carlo is offline
external usenet poster
 
Posts: 367
Default Formula to consolidate numbers?

You're very welcome

Carlo

On Dec 6, 7:53 pm, Chartreuse
wrote:
Hi, Carlo, thank you so much. :) Your macro worked great! :)



"carlo" wrote:
this should do the job:


---------------------------------------------
Sub consol()


Dim f_number As Long
Dim l_number As Long
Dim sh_ As Worksheet


Set sh_ = Worksheets("sheet2")


f_number = Cells(2, 1)
l_number = Cells(2, 2)


j = 1


For i = 3 To Cells(65536, 1).End(xlUp).Row
If Cells(i, 1).Value < l_number + 1 Then
sh_.Cells(j, 1) = f_number
sh_.Cells(j, 2) = l_number
f_number = Cells(i, 1)
j = j + 1
End If
l_number = Cells(i, 2)
Next i


sh_.Cells(j, 1) = f_number
sh_.Cells(j, 2) = l_number


End Sub
-------------------------------------------------------


exchange sheet2 with whatever your output sheet should be.


the sheet you want to consolidate has to be the activesheet, otherwise
it won't work (i was to lazy to do it properly, sorry!)


hth


Carlo


On Dec 6, 11:22 am, FJ wrote:
Hi, I have I have a spreadsheet with about 65,000 rows. I have to
consolidate the data so that ranges of numbers with no breaks (in other
words, where the numbers increase by one) will appear in one cell. The data
looks something like this:


Beginning # Ending #
60220718 60220719
60220720 60220720
60220721 60220731
60220732 60220732
60220733 60220757
40006024 40006025
40006026 40006029
40006030 40006031


Basically, what I have to do is consolidate the data so that it will look
like this:


60220718-60220757
40006024-40006031


Is there any way to write a formula or a macro to do this?


Thanks in advance for any information.- Hide quoted text -


- Show quoted text -