+ Reply to Thread
Results 1 to 14 of 14

Compare Two column cells

  1. #1
    Registered User
    Join Date
    07-12-2019
    Location
    Germany
    MS-Off Ver
    Office365
    Posts
    61

    Compare Two column cells

    Hello All,
    I want to write a VBA macro to compare cells of column B and E. Comparing cells from row 3, 4 and 5 are easy but difficulty level is in row 6, 7 and 8. when comparing E6 to B6 i have to take a * value and this value could be A,B,C,D,E,F,G,H,J,L,M as highlighted in the figure. So if in B6 cell A (in red colour) is present instead of * so this means -F* in cell E6 could be -FA as A is the possible value of *.

    Similarly the case in comparing B7 to E7 and, B8 to E8. I want to write a macro that do it automatically as data will be variable. Workbook is already attached. Help me with this Please! Thank you
    Attached Images Attached Images
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Compare Two column cells

    How do you know which list to use to replace the *, is it due the letter before and after the * ??
    - Battle without fear gives no glory - Just try

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Compare Two column cells

    Why do you show B4 & E4 as a mismatch? They look the same to me.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Registered User
    Join Date
    07-12-2019
    Location
    Germany
    MS-Off Ver
    Office365
    Posts
    61
    Quote Originally Posted by PCI View Post
    How do you know which list to use to replace the *, is it due the letter before and after the * ??
    I look for a red letter (after - F for example) in a corresponding cell of column A and then see if this letter can be replaced for *. And this possibility will be according to the list of letters highlighted in yellow

  5. #5
    Registered User
    Join Date
    07-12-2019
    Location
    Germany
    MS-Off Ver
    Office365
    Posts
    61
    Quote Originally Posted by Richard Buttrey View Post
    Why do you show B4 & E4 as a mismatch? They look the same to me.
    My mistake sorry!

  6. #6
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Compare Two column cells

    this possibility will be according to the list of letters highlighted in yellow
    It means for each row where exists * there is a yellow list on the same row ???

  7. #7
    Registered User
    Join Date
    07-12-2019
    Location
    Germany
    MS-Off Ver
    Office365
    Posts
    61
    Quote Originally Posted by PCI View Post
    It means for each row where exists * there is a yellow list on the same row ???
    Yes, I can put if it helps to make program easy

  8. #8
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Compare Two column cells

    Yes, I can put if it helps to make program easy
    Wait, wait, the question is, does the yellow list linked to the * on the same row ?
    In other words if a * is found where to search to get the characters list to replace it ?

  9. #9
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Compare Two column cells

    Maybe in F3 copied down

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    07-12-2019
    Location
    Germany
    MS-Off Ver
    Office365
    Posts
    61
    Quote Originally Posted by PCI View Post
    Wait, wait, the question is, does the yellow list linked to the * on the same row ?
    In other words if a * is found where to search to get the characters list to replace it ?
    For example if a * is found in E6 Then we look in B6 which letter is in place of * in B6 then we we to yellow list and see if we can place this letter in E6. (here letter was A(red color) and we saw in the yellow list * could be equal to A)

  11. #11
    Registered User
    Join Date
    07-12-2019
    Location
    Germany
    MS-Off Ver
    Office365
    Posts
    61

    Re: Compare Two column cells

    Hi Richard,
    This formula is working correctly and doing the exact job.But I want to do it through VBA macro can you help me to write the code?

  12. #12
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Compare Two column cells

    Why not just use VBA to add that formula for you.
    Assuming it's column A that determines the last cell with a value and hence how far down column F you want to copy then

    Please Login or Register  to view this content.
    Sheet1 is the VBA sheet code name (NOT the tab name) change this as necessary

  13. #13
    Registered User
    Join Date
    07-12-2019
    Location
    Germany
    MS-Off Ver
    Office365
    Posts
    61

    Re: Compare Two column cells

    There is still one problem with the formula. With MID search it is also matching the letters other then in the place of *. In the attached pic one can see that it is also considering the before and after letters of * and gives wrong answer
    Attached Images Attached Images

  14. #14
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Compare Two column cells

    See next code
    Please Login or Register  to view this content.
    Last edited by PCI; 01-09-2020 at 04:27 AM. Reason: Code updated to be smarter

+ 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] Compare a row of cells with a column
    By Xenthys in forum Excel General
    Replies: 2
    Last Post: 11-26-2019, 02:17 PM
  2. Select 2 cells in same column, compare against sum of 2 cells in diff column
    By johndoe15 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-04-2017, 12:09 PM
  3. HELP! Compare cells of a column to same column in different workbook and highlight diffs
    By bradleyherron in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-05-2014, 10:18 AM
  4. How to compare cells among each other in the same column
    By SPstudent in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-16-2012, 10:12 AM
  5. Compare cells in column 1 and concatenate values in column 2
    By sharmaremuk in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 07-20-2011, 09:04 PM
  6. Replies: 0
    Last Post: 07-27-2010, 03:08 PM
  7. How do I compare cells in a column
    By Jim K in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 01-29-2005, 08:07 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