+ Reply to Thread
Results 1 to 2 of 2

Extracting and reorganizing values in cells

  1. #1
    Valued Forum Contributor Melvinrobb's Avatar
    Join Date
    06-19-2012
    Location
    Manitoba, Canada
    MS-Off Ver
    Excel 2013
    Posts
    1,128

    Extracting and reorganizing values in cells

    Hi all

    I'm looking to create my own list of Zip codes and the city that applies to them.
    I found the info I want on this website: http://en.wikipedia.org/wiki/List_of_ZIP_code_prefixes
    The attached file is what I got when I copy and pasted the info in excel. What I want is to list the data in the Structure in columns M-P.
    I can do this manually, but that would take a while. I'm sure someone knows formulas to quickly draw out the info.
    Attached Files Attached Files
    Please click the * icon below if I have helped.

  2. #2
    Forum Contributor
    Join Date
    07-27-2012
    Location
    California, USA
    MS-Off Ver
    Excel 2003
    Posts
    198

    Re: Extracting and reorganizing values in cells

    VBA code in the attached Excel 2003 file translates the zip prefix report in Sheet1,
    from vertical to horizontal display of records and writes the rearranged text in Sheet2.
    This code would be useful if you had to do this chore more than once. Otherwise,
    it just illustrates that any Excel report that has a predictable order to it, can be parsed
    and put in some other orderly format.

    The original list displays each record’s fields in a column, using 2 or 3 rows per record,
    and records are displayed across 10 columns. In each column, one record follows another
    without skipping rows, except for dual blank rows that appear to be page-separators.

    Formulas could be used but there would be some manual clean-up steps in getting
    the results in finished format. VBA code does it all in a second or two.
    The code parses the zip prefix from the state abbreviation and stores each in a separate cell.

    Steps the code goes through:

    - loop through all rows and record in an array, the starting row of each set of 10 records.
    Since we now have this information, besides having a reference for starting rows,
    we don’t have to worry about the blank page-separator rows in Sheet1, because of the
    fact that the 2 or 3 rows following the starting row have data.

    - new outer loop: using the record starting row # as a reference, determine if the
    current set of 10 records uses 2 rows per record or 3.

    - inner loop: capture either 2 or 3 cell values for each individual record and
    write results in Sheet2, repeating this for all 10 columns.

    - repeat the above 2 steps until all rows in the array of record row-starting numbers have been processed.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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