+ Reply to Thread
Results 1 to 6 of 6

VBA code to identify a continuous range

  1. #1
    Registered User
    Join Date
    04-28-2013
    Location
    Bangalore
    MS-Off Ver
    Excel 2010
    Posts
    81

    VBA code to identify a continuous range

    Hi

    If I have a range

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

    my macro should pick up the start range as 1 and end range as 15

    if the range is

    1 3 4 5 6 9 11 12 13 14 15

    my macro shoul pick up

    1 as a start 1 ,3 as start2 range and 5 as end2 , 9 as start3, 11 as start 4 and 15 as end15

    if the range is

    1 2 3 4 7 9 10 11 12 13 then

    1 is start1 4 is end1, 7 is start2, 9 is start3 13 is end3

    or even if my macro can high light the ones in color it is fine

    Basically identify a range and pick the start and end for each of the range and delete the inbetween numbers and retain the number which doesnt belong to the continuous series

  2. #2
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: VBA code to identify a continuous range

    Try this on numbers in row 1.
    NB:- See code comments to delete or Colour unwanted columns !!!
    Please Login or Register  to view this content.
    Regards Mick

  3. #3
    Registered User
    Join Date
    04-28-2013
    Location
    Bangalore
    MS-Off Ver
    Excel 2010
    Posts
    81

    Re: VBA code to identify a continuous range

    Hi this code removes the unwanted set of numbers..But needs to return the result in sets
    like

    1 to 4 is consequitive numbers so remove 2 n 3
    9 to 13 is consequitive so remove 10,11 and 12
    1-4,7,9-13
    Last edited by rshnkmr39; 11-07-2014 at 05:14 PM.

  4. #4
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: VBA code to identify a continuous range

    On the basis you want each set in a different cell, try this.
    Results start "A5"
    Please Login or Register  to view this content.
    Regards Mick
    Last edited by MickG; 11-08-2014 at 06:59 AM.

  5. #5
    Registered User
    Join Date
    04-28-2013
    Location
    Bangalore
    MS-Off Ver
    Excel 2010
    Posts
    81

    Re: VBA code to identify a continuous range

    WOw.This is amazing.Thanks a ton.

  6. #6
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: VBA code to identify a continuous range

    You're welcome

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 0
    Last Post: 02-20-2012, 05:42 PM
  2. Continuous Range
    By DSC174 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-10-2005, 01:05 PM

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