+ Reply to Thread
Results 1 to 3 of 3

Code selects first and last rows with consecutive values and with unique values

  1. #1
    Valued Forum Contributor
    Join Date
    01-16-2012
    Location
    England
    MS-Off Ver
    MS 365
    Posts
    1,397

    Code selects first and last rows with consecutive values and with unique values

    Attached file Postcode summary.xlsx contains a list of Towns and Postcodes in Cols A and B, and shows in Cols F - H what I need to produce.

    Objective:

    If a Town has consecutive Postcodes, "copy and paste" the first and last values from the range onto one row for each Town.
    If the postcodes are NOT consecutive, each one goes on a row of it's own.

    I created a Macro that worked for US "Zip Codes" because they are purely numeric.

    What is defeating me is the Code that "recognises" the alphanumeric pattern so it "sees" AL1, AL2 and AL3 as "consecutive" but AL5 as "unique"

    Sure it's staring me in the face.

    Any suggestions and guidance accepted gratefully

    Ochimus

  2. #2
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: Code selects first and last rows with consecutive values and with unique values

    Why would your first town be AL1 to AL3 instead of AL1 to AL4?
    Click the * Add Reputation button in the lower left hand corner of this post to say thanks.

    Don't forget to mark this thread SOLVED by going to the "Thread Tools" drop down list above your first post and choosing solved.

  3. #3
    Valued Forum Contributor
    Join Date
    01-16-2012
    Location
    England
    MS-Off Ver
    MS 365
    Posts
    1,397

    Re: Code selects first and last rows with consecutive values and with unique values

    skywriter,

    Apologies for delay in replying, but had to pop into hospital shortly after I posted the query last week.

    You are quite right. In the attachment I sent the first bloc should have been AL1 - AL4, then AL6 as a "unique" before moving on to the next town.

    But sadly I'm no nearer working out how to achieve it either way!

    Ochimus

+ 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. [SOLVED] Macro that merges duplicate rows based on unique values - Need to edit current code
    By niya429 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-27-2014, 02:57 PM
  2. Replies: 1
    Last Post: 04-11-2013, 01:02 PM
  3. Code selects entire rows upto one range and same code selects only columns for other.
    By sriharigk in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-09-2012, 05:19 AM
  4. Replies: 0
    Last Post: 06-15-2011, 09:46 AM
  5. Combining Values in rows and keeping unique values (adv. filtering?)
    By nguyeda in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-26-2011, 01:48 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