+ Reply to Thread
Results 1 to 7 of 7

Matching State City Zip Code Pattern before transposing to corresponding cell

  1. #1
    Registered User
    Join Date
    08-23-2014
    Location
    Miami, USA
    MS-Off Ver
    365
    Posts
    69

    Unhappy Matching State City Zip Code Pattern before transposing to corresponding cell

    I have a bunch of contacts listed in column B which I´m transposing to a specific cells according to their data. I need to write VBA code that will always transpose the row that contains the CITY STATE ZIP CODE information to the corresponding cell.
    This is part of my code that I have:

    If Rng.Areas(Grp).Cells(Itm) Like "*[a-z],*[A-Z][A-Z]*#####*" Then ……

    This works fine if the row contains: Lynchburg, VA 24503

    But I also have a row that has: Karen C. Metz, NMLS #223664 and will accidentally place this data under the wrong cell value. It might also just have the City and State but no zip code: Lynchburg, VA

    I think the key part is having the VBA code identify the two capital letters of the State within the string and then identify this row as the CITY value before transposing it to the appropriate column. I think this is the way to go because my data will always have the two letter state code.

    I’ve attached my current code to see what I’m talking about, please help, I’m a newbie to VBA so my current code is not the best. Any suggestions or a better way to do this will be greatly appreciated.
    Thanks
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Matching State City Zip Code Pattern before transposing to corresponding cell

    What do you want to do with Ruiel Export and Karen? Where should they go?
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    08-23-2014
    Location
    Miami, USA
    MS-Off Ver
    365
    Posts
    69

    Re: Matching State City Zip Code Pattern before transposing to corresponding cell

    Rueil is fine under City, since it's in France, but Karen C.Metz should go under Contact.
    Thanks

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Matching State City Zip Code Pattern before transposing to corresponding cell

    Based on your fist post, I didn't think you would keep one of the two.
    It sounded like you wanted to determine US States only versus everything else.

    If you keep Rueil as a city, then what pattern could distinguish
    the US States AND Rueil-Malmaison, FRA 92500 as a city
    from
    Karen C. Metz, NMLS #223664 and Kenneth Cobbs, II

  5. #5
    Registered User
    Join Date
    08-23-2014
    Location
    Miami, USA
    MS-Off Ver
    365
    Posts
    69

    Re: Matching State City Zip Code Pattern before transposing to corresponding cell

    Yes you are right alphafrog, all I care about it US states. Please ignore Rueil-Malmaison or delete

  6. #6
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Matching State City Zip Code Pattern before transposing to corresponding cell

    This matches state codes and FRA preceded by a comma-space

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    08-23-2014
    Location
    Miami, USA
    MS-Off Ver
    365
    Posts
    69

    Re: Matching State City Zip Code Pattern before transposing to corresponding cell

    PERFECT alphafrog!!! This is exactly what I needed, thank you so much.

+ 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. autofill city and state when typing in zip code
    By shughes6288 in forum Excel General
    Replies: 7
    Last Post: 01-07-2016, 12:35 PM
  2. Parsing City State and Zip Code
    By sandy1977 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-27-2014, 11:58 AM
  3. zip code to city, state function
    By xip in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 06-07-2012, 10:12 PM
  4. zip code to city, state function
    By xcelentform in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-18-2006, 07:10 PM
  5. Replies: 6
    Last Post: 02-06-2005, 10:06 PM

Tags for this Thread

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