PC Review


Reply
Thread Tools Rate Thread

Compare 2 list and extract continous range

 
 
Tamil
Guest
Posts: n/a
 
      15th Dec 2006
Hello,

This is my first post. I have two list of data and want to extract
continous range.
eg. 1 2
2 3
5 6
6 7
8 10

I want continous range like
1 3
5 7
8 10

I have to handle large data. Either formula or query is required.

Thanks,
Panneer selvam

 
Reply With Quote
 
 
 
 
NickHK
Guest
Posts: n/a
 
      15th Dec 2006
I understand the 1-3 and possibly the 5-7, but how is 8 10 continuous ?
Also it is not 5-8 as continuous ?

Or are there other rules ?

NickHK

"Tamil" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello,
>
> This is my first post. I have two list of data and want to extract
> continous range.
> eg. 1 2
> 2 3
> 5 6
> 6 7
> 8 10
>
> I want continous range like
> 1 3
> 5 7
> 8 10
>
> I have to handle large data. Either formula or query is required.
>
> Thanks,
> Panneer selvam
>



 
Reply With Quote
 
=?Utf-8?B?TWFydGluIEZpc2hsb2Nr?=
Guest
Posts: n/a
 
      15th Dec 2006
Panneer:

Is this what you want?

Option Explicit

Sub makelist()

Dim rSel As Range
Dim x1, x2
Dim lRowStart As Long, lRowEnd As Long
Dim lRow As Long, lRowAns As Long
Dim lCol1 As Long, lCol2 As Long

Set rSel = Selection

lCol1 = rSel.Column
lCol2 = lCol1 + rSel.Columns.Count - 1
lRowStart = rSel.Row
lRowEnd = lRowStart + rSel.Rows.Count - 1
lRowAns = lRowEnd + 3

x1 = Cells(lRowStart, lCol1)
x2 = Cells(lRowStart, lCol2)

For lRow = lRowStart + 1 To lRowEnd Step 1
If x2 <> Cells(lRow, lCol1) Then
Cells(lRowAns, lCol1) = x1
Cells(lRowAns, lCol2) = x2
lRowAns = lRowAns + 1
x1 = Cells(lRow, lCol1)
x2 = Cells(lRow, lCol2)
Else
x2 = Cells(lRow, lCol2)
End If
Next lRow

Cells(lRowAns, lCol1) = x1
Cells(lRowAns, lCol2) = x2

End Sub

> eg. 1 2
> 2 3
> 5 6
> 6 7
> 8 10
>
> I want continous range like
> 1 3
> 5 7
> 8 10


--
Hope this helps
Martin Fishlock
Please do not forget to rate this reply.


"Tamil" wrote:

> Hello,
>
> This is my first post. I have two list of data and want to extract
> continous range.
> eg. 1 2
> 2 3
> 5 6
> 6 7
> 8 10
>
> I want continous range like
> 1 3
> 5 7
> 8 10
>
> I have to handle large data. Either formula or query is required.
>
> Thanks,
> Panneer selvam
>
>

 
Reply With Quote
 
Tamil
Guest
Posts: n/a
 
      15th Dec 2006
Fantastic Mr.Martin,

Thanks a lot.

This is what I required.

You saved much time for my routine work.

Hats off to Google group.

- Panneer

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
HELP copy non-continous range Marina Microsoft Excel Programming 2 28th Oct 2009 04:21 PM
Compare date to list/range of dates (complicated) Jaazaniah Microsoft Access Queries 1 24th Apr 2009 12:18 AM
Extract data from a list within a specific date range Jennifer Bremer Microsoft Excel Worksheet Functions 4 8th Nov 2003 10:29 PM
Re: deleting rows in a non-continous range kiat Microsoft Excel Programming 0 22nd Aug 2003 03:23 PM
Re: deleting rows in a non-continous range Michael Tomasura Microsoft Excel Programming 0 22nd Aug 2003 03:58 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:00 AM.