+ Reply to Thread
Results 1 to 10 of 10

Compare two columns BUT accept switched first name and last name

  1. #1
    Registered User
    Join Date
    12-16-2014
    Location
    Czech
    MS-Off Ver
    2010
    Posts
    18

    Compare two columns BUT accept switched first name and last name

    Hello,

    I am trying to compare two columns on different worksheets.
    The problem occurs when I am trying to compare namesin column B.
    This is what Ive got so far, please ignore my messy code.
    Please Login or Register  to view this content.
    Macro wont do
    Please Login or Register  to view this content.
    unless names match 100% but I want highlight them even it is comparing switched first and last name.

    For example:

    John Smith on activesheet will be highlighted when John smith is somewhere in column B on other sheets BUT
    John Smith will not be highligted on activesheet when on othersheet he is stored as Smith John.

    Can you please advice me how to proceed?

    Thanks in advance!

  2. #2
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,173

    Re: Compare two columns BUT accept switched first name and last name

    Edit: Comment Removed

  3. #3
    Registered User
    Join Date
    12-16-2014
    Location
    Czech
    MS-Off Ver
    2010
    Posts
    18

    Re: Compare two columns BUT accept switched first name and last name

    I am thinking about selecting last name via InStr MID and comparing the string after space f.e. but this solution will not be universal because like I said I can get a sheet with Smith John and then the code will compare just string John which is highly common

    Edit:
    something like that
    Please Login or Register  to view this content.
    Last edited by pandemic; 03-20-2015 at 11:30 AM.

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    20,047

    Re: Compare two columns BUT accept switched first name and last name

    Quote Originally Posted by pandemic View Post
    For example:

    John Smith on activesheet will be highlighted when John smith is somewhere in column B on other sheets BUT
    John Smith will not be highligted on activesheet when on othersheet he is stored as Smith John.

    Can you please advice me how to proceed?

    Thanks in advance!
    Function to retrn True/False
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    12-16-2014
    Location
    Czech
    MS-Off Ver
    2010
    Posts
    18

    Re: Compare two columns BUT accept switched first name and last name

    Quote Originally Posted by jindon View Post
    Function to retrn True/False
    Please Login or Register  to view this content.

    Can you please advice me how can I call your function in my code?

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    20,047

    Re: Compare two columns BUT accept switched first name and last name

    Perhaps,
    Please Login or Register  to view this content.
    To
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    12-16-2014
    Location
    Czech
    MS-Off Ver
    2010
    Posts
    18

    Re: Compare two columns BUT accept switched first name and last name

    The compiler error message:

    Sub or Function not defined

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    20,047

    Re: Compare two columns BUT accept switched first name and last name

    Did you insert Function "CompareNames" that I have posted to a standard module?

    That error occurs when it doesn't find the function.

  9. #9
    Registered User
    Join Date
    12-16-2014
    Location
    Czech
    MS-Off Ver
    2010
    Posts
    18

    Re: Compare two columns BUT accept switched first name and last name

    Yes,

    Im writing this code in Module 1

    http://imgur.com/yidweCT

  10. #10
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    20,047

    Re: Compare two columns BUT accept switched first name and last name

    Where did you place the following code I posted in #4?
    Please Login or Register  to view this content.

+ 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: 3
    Last Post: 11-26-2014, 12:48 PM
  2. [SOLVED] Day and Month of the date switched!
    By kisa159 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-13-2014, 09:17 AM
  3. [SOLVED] Modify macro to repeat once, accept a different file type and paste into different columns
    By vegetable in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-07-2013, 12:46 PM
  4. Copying formulae switched off
    By Leroyloverod in forum Excel General
    Replies: 3
    Last Post: 03-27-2007, 06:46 AM
  5. DSUM Switched Off?
    By timwerx in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-24-2006, 12:17 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