+ Reply to Thread
Results 1 to 2 of 2

Need to format two groups of zip codes so they work for exact matching

  1. #1
    Registered User
    Join Date
    08-22-2023
    Location
    Pennsylvania, USA
    MS-Off Ver
    365
    Posts
    3

    Need to format two groups of zip codes so they work for exact matching

    Hi,

    Thanks in advance for your time.

    I have two columns of zip codes taken from separate web sources that I need to match with if() functions and various other exact matching functions like vlookup() and match().

    The problem is, no matter what I do, the zip codes will not format identically. I believe it has to do with their number format, because one of the groups pastes into Excel in the "general" format, but somehow has leading zeros still attached. The other group also pastes in "general" with leading zeros, but sometimes after editing this group the leading zeros disappear. I have no idea why the two columns are behaving differently, they both paste in general with leading zeros, but one group never loses its leading zeros, even when I try to force it. I have tried several methods, detailed below.

    -I put both columns through the =clean(text("zipcode", "00000"), then pasted values only to a new column. This does not work even though visually, the values are all five-digit general numbers with a single trailing space.

    -I put both columns through the =trim("zipcode") function, then pasted values only to a new column. This gives the same results as the first attempt, visually everything matches but it won't work with the matching formulas.

    -I used data -> text to columns with no delimiters selected to force everything into general format, but this doesn't work either. It removes leading zeros from one set, but not the other.

    When using conditional formatting to highlight duplicates, there are no duplicates between columns, even though they appear to be identical in every sense.

    Does anyone know a formula or method, not mentioned above, that can force zip codes to be identical so they work with exact match formulas? Or does someone know of a possible error that could be causing this issue?
    I truly have no idea what is going on here and I am at the end of my rope. I feel like I'm going crazy haha. Please help!!!

    Thank you!

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,453

    Re: Need to format two groups of zip codes so they work for exact matching

    Matching/IF()/lookup functions should not be affected by number formatting. Functions use the value stored in the cell and don't look at the number formatting.

    I would guess that you have non-printing characters in some of what you are pasting from the web. If I were to debug this, I would probably start by pasting a sampling of zip codes into Excel, then use something like UNICODE(MID(zip code text,1...Len(zip code text),1) [pseudo-formula, not syntactically correct, so you can't just paste this into Excel] and see what characters are being pasted into Excel.

    Once I know what characters are being pasted into Excel, then I would identify the actual zip-code characters and the extraneous characters. Then figure out a way to extract just the zip-code characters and get rid of the garbage characters. Note that CLEAN() and TRIM() only work on some characters (mostly the basic ASCII character list) and do not clean out higher coded characters (like the space 160 character).

    Once I have figured out how to clean off all of the garbage characters, then you will need to decide how you want to store you zip codes. If you are working with basic 5 digit US zip codes, then i would probably store them as 5 digit numbers (avoid storing numbers stored as text). If you have 5 + 4 digit US zip codes, then store as 9 digit numbers (formatted as 00000-0000). If you have a mix of 5 digit zip codes and 5+4, then you will need to think about how to handle those differences. If you want to extend this to international postal codes (that can use both alphabetic and numeric characters in different combinations), then you may want to store all of the zip codes as text and always search using "numbers stored as text."

    That's what I would do. I think it's important to start with a careful analysis of the text you are pasting into Excel so you can get a reliable method of cleaning the text of any of the garbage characters that are often a part of web data pasted into Excel. Once you have a reliable method of cleaning the text data, I expect the rest of the project will be relatively straightforward.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

+ 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] Help with Power Query to extract only matching codes from reference codes
    By chandramouliarun in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-07-2022, 05:57 AM
  2. Added codes to macro and some codes no longer work
    By alisoncleverly in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-14-2020, 01:26 PM
  3. [SOLVED] matching exact format as template when copy/paste issue
    By Pi* in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-28-2017, 11:14 PM
  4. [SOLVED] Need a macro to split 5020 codes into groups by 220 each
    By Arty_1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-19-2014, 08:47 AM
  5. Formula to work out an exact average over an exact number
    By Sandyshirl in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 06-11-2013, 01:35 AM
  6. Assigning job codes into corresponding job code groups
    By ngiachino in forum Excel General
    Replies: 4
    Last Post: 03-11-2009, 03:39 PM
  7. matching codes between 2 item codes
    By JChan in forum Excel General
    Replies: 1
    Last Post: 10-15-2005, 01:05 AM

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