Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
FJ FJ is offline
external usenet poster
 
Posts: 90
Default Formula to consolidate numbers?

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.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 367
Default Formula to consolidate numbers?

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.


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default Formula to consolidate numbers?

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.



  #4   Report Post  
Posted to microsoft.public.excel.misc
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 -


  #5   Report Post  
Posted to microsoft.public.excel.misc
FJ FJ is offline
external usenet poster
 
Posts: 90
Default Formula to consolidate numbers?

Hi, Carlo, thanks again for your help the other day. I actually have another
question about this macro. We've been given a new project. It is the same
as the old one you wrote the macro for. The only difference is that this
time the data has letters in front of the numbers. Is there any way to
change the macro so that it would do the same thing as before but include the
letters in front of the numbers?

In other words, we have the following data:

Beginning # Ending #
XYZ60220718 XYZ60220719
XYZ60220720 XYZ60220720
XYZ60220721 XYZ60220731
XYZ60220732 XYZ60220732
XYZ60220733 XYZ60220757
FMTY40006024 FMTY40006025
FMTY40006026 FMTY40006029
FMTY40006030 FMTY40006031

And ultimately they would like it to look as follows:

Beginning # Ending #
XYZ60220718 XYZ60220757
FMTY40006024 FMTY40006031

I tried to do it by first separating the text from the numbers, then running
the macro, then recombining the text and the numbers using formulas, but for
reasons that are difficult to explain here I don't seem to get the correct
result with all the entries when everything is recombined. I guess maybe
this sort of thing would have to be written into the macro code, although I
don't know. Unfortunately, I have almost no knowledge of VBA.

Thank you in advance for any help.




"carlo" wrote:

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 -





  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 367
Default Formula to consolidate numbers?

Hi FJ

that should be possible.
But i have some questions concerning the structu
is it possible, that there are numbers between the letters??
-- like AAA9A99999
Are your fields sorted according to the letters?

I will tell you as soon as i have some code.

cheers carlo

On Dec 7, 7:16 pm, FJ wrote:
Hi, Carlo, thanks again for your help the other day. I actually have another
question about this macro. We've been given a new project. It is the same
as the old one you wrote the macro for. The only difference is that this
time the data has letters in front of the numbers. Is there any way to
change the macro so that it would do the same thing as before but include the
letters in front of the numbers?

In other words, we have the following data:

Beginning # Ending #
XYZ60220718 XYZ60220719
XYZ60220720 XYZ60220720
XYZ60220721 XYZ60220731
XYZ60220732 XYZ60220732
XYZ60220733 XYZ60220757
FMTY40006024 FMTY40006025
FMTY40006026 FMTY40006029
FMTY40006030 FMTY40006031

And ultimately they would like it to look as follows:

Beginning # Ending #
XYZ60220718 XYZ60220757
FMTY40006024 FMTY40006031

I tried to do it by first separating the text from the numbers, then running
the macro, then recombining the text and the numbers using formulas, but for
reasons that are difficult to explain here I don't seem to get the correct
result with all the entries when everything is recombined. I guess maybe
this sort of thing would have to be written into the macro code, although I
don't know. Unfortunately, I have almost no knowledge of VBA.

Thank you in advance for any help.



"carlo" wrote:
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 -- Hide quoted text -


- Show quoted text -


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Consolidate formula Atul Jadhav[_2_] Excel Worksheet Functions 1 May 29th 07 11:44 AM
Excel Formula - Add column of numbers but ignore negative numbers view for Distribution List members Excel Worksheet Functions 1 April 7th 06 03:13 AM
Help! How do you get excel to find the x(changes daily, marked in a cell from another formula) highest numbers in a group of numbers and sum them up? C-Man23 Excel Worksheet Functions 3 January 19th 06 09:52 AM
Help! How do you get excel to find the x(changes daily, marked in a cell from another formula) highest numbers in a group of numbers and sum them up? C-Man23 Excel Worksheet Functions 1 January 9th 06 01:23 PM
Consolidate of data using formula in Excel ims Excel Worksheet Functions 7 December 28th 05 05:08 PM


All times are GMT +1. The time now is 10:55 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"