+ Reply to Thread
Results 1 to 18 of 18

How to compare two columns in excel using VBA formula

  1. #1
    Registered User
    Join Date
    11-22-2012
    Location
    Kolkata,India
    MS-Off Ver
    Excel 2003
    Posts
    11

    How to compare two columns in excel using VBA formula

    Hi friends,
    I need a formula by which contents of two columns can be compared

    A(Index) B(Type) C
    Test1 Value True
    Test1 Value True
    Test1 Percentage False

    ColumnC will return False if the same element in ColumnA has different Types in ColumnB.
    Last edited by Kuntal; 11-22-2012 at 05:22 AM.

  2. #2
    Forum Contributor
    Join Date
    08-23-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    163

    Re: How to compare two columns in excel using VBA formula

    somthing like...

    =IF(A2=A1,IF(B2=B1,"True","False"),"True")

  3. #3
    Registered User
    Join Date
    11-22-2012
    Location
    Kolkata,India
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: How to compare two columns in excel using VBA formula

    Its not working...

  4. #4
    Forum Contributor satputenandkumar0's Avatar
    Join Date
    11-08-2012
    Location
    Pune, India
    MS-Off Ver
    Office xp & Office 2007
    Posts
    398

    Re: How to compare two columns in excel using VBA formula

    Hi, welcome to the forum!

    Could you upload a sample sheet so that we may help you better?

    Click on Go Advanced below this thread and then on 'Manage Attachments'.

  5. #5
    Registered User
    Join Date
    11-22-2012
    Location
    Kolkata,India
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: How to compare two columns in excel using VBA formula

    Col D contains the desired results.
    Attached Files Attached Files

  6. #6
    Forum Contributor
    Join Date
    08-23-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    163

    Re: How to compare two columns in excel using VBA formula

    no sure how thats not working for you....could you please check the attached sheet
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    11-22-2012
    Location
    Kolkata,India
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: How to compare two columns in excel using VBA formula

    Quote Originally Posted by [email protected] View Post
    no sure how thats not working for you....could you please check the attached sheet

    Ur Formula is working only if continuity is maintained. Which is unlikely. Red legends in the excel are the errors.
    Attached Files Attached Files

  8. #8
    Forum Contributor
    Join Date
    08-23-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    163

    Re: How to compare two columns in excel using VBA formula

    Hi....got it now
    Below might be helpful. Please find attached the revised sheet.

    =IF(B2=VLOOKUP(A2,A:B,2,0),"True","False")
    Attached Files Attached Files

  9. #9
    Forum Contributor
    Join Date
    09-27-2012
    Location
    London, England
    MS-Off Ver
    2003, 2010
    Posts
    344

    Re: How to compare two columns in excel using VBA formula

    Hi Kuntal,

    Not sure if this is what you want but give it a try.

    In cell E2 and below use the below formula (use this as a helper column):

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


    Then in cell F2 and below:

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


    Wherever you get the message "Repeated Entry" it would mean that combination of Index and Value are already appearing somewhere else in the dataset and where it says "Single Entry" those would be unique records.

    Does that help?
    If solved kindly remember to mark Thread as solved.
    Click the small star icon at the bottom left of my post if this was useful.

  10. #10
    Registered User
    Join Date
    11-22-2012
    Location
    Kolkata,India
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: How to compare two columns in excel using VBA formula

    Quote Originally Posted by kbkumar View Post
    Hi Kuntal,

    Not sure if this is what you want but give it a try.

    In cell E2 and below use the below formula (use this as a helper column):

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


    Then in cell F2 and below:

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


    Wherever you get the message "Repeated Entry" it would mean that combination of Index and Value are already appearing somewhere else in the dataset and where it says "Single Entry" those would be unique records.

    Does that help?
    Not working...

  11. #11
    Forum Contributor
    Join Date
    09-27-2012
    Location
    London, England
    MS-Off Ver
    2003, 2010
    Posts
    344

    Re: How to compare two columns in excel using VBA formula

    Upload your workbook and state the desired output...

  12. #12
    Registered User
    Join Date
    11-22-2012
    Location
    Kolkata,India
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: How to compare two columns in excel using VBA formula

    Quote Originally Posted by kbkumar View Post
    Upload your workbook and state the desired output...
    Check the output.
    Attached Files Attached Files

  13. #13
    Forum Contributor
    Join Date
    08-23-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    163

    Re: How to compare two columns in excel using VBA formula

    Hi Kuntal,

    have you checked the revised formula in my earlier post? This works for all cases in your attachment.

    PFA

    =IF(B2=VLOOKUP(A2,A:B,2,0),"True","False").
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    11-22-2012
    Location
    Kolkata,India
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: How to compare two columns in excel using VBA formula

    Quote Originally Posted by [email protected] View Post
    Hi....got it now
    Below might be helpful. Please find attached the revised sheet.

    =IF(B2=VLOOKUP(A2,A:B,2,0),"True","False")
    Yes it works.. But can you plz make it work in this sheet.
    Also plz explain how it works.
    Attached Files Attached Files

  15. #15
    Forum Contributor
    Join Date
    08-23-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    163

    Re: How to compare two columns in excel using VBA formula

    Hi,

    Please find attached the updated sheet.

    1) VLOOKUP(C4,C:E,3,0): The formula will lookup intex type for each index name. So, for T1 index type would be "Value" and for T2 "Percentage".
    2) IF(E4=VLOOKUP(C4,C:E,3,0),"True","False"): This will compare E4 with the value of lookup as above. If it matches, then true else false.
    Attached Files Attached Files

  16. #16
    Registered User
    Join Date
    11-22-2012
    Location
    Kolkata,India
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: How to compare two columns in excel using VBA formula

    Quote Originally Posted by [email protected] View Post
    Hi,

    Please find attached the updated sheet.

    1) VLOOKUP(C4,C:E,3,0): The formula will lookup intex type for each index name. So, for T1 index type would be "Value" and for T2 "Percentage".
    2) IF(E4=VLOOKUP(C4,C:E,3,0),"True","False"): This will compare E4 with the value of lookup as above. If it matches, then true else false.
    Thnx a lot Sir...

  17. #17
    Registered User
    Join Date
    11-22-2012
    Location
    Kolkata,India
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: How to compare two columns in excel using VBA formula

    Quote Originally Posted by [email protected] View Post
    Hi,

    Please find attached the updated sheet.

    1) VLOOKUP(C4,C:E,3,0): The formula will lookup intex type for each index name. So, for T1 index type would be "Value" and for T2 "Percentage".
    2) IF(E4=VLOOKUP(C4,C:E,3,0),"True","False"): This will compare E4 with the value of lookup as above. If it matches, then true else false.
    Thanx a lot Sir...

  18. #18
    Registered User
    Join Date
    11-22-2012
    Location
    Kolkata,India
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: How to compare two columns in excel using VBA formula

    Quote Originally Posted by [email protected] View Post
    Hi,

    Please find attached the updated sheet.

    1) VLOOKUP(C4,C:E,3,0): The formula will lookup intex type for each index name. So, for T1 index type would be "Value" and for T2 "Percentage".
    2) IF(E4=VLOOKUP(C4,C:E,3,0),"True","False"): This will compare E4 with the value of lookup as above. If it matches, then true else false.
    Now I need to see if same Index has been written for the same Date. If in the same date there is more than one Index of same Name the give False. Plz help me out.
    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