Results 1 to 4 of 4

Finding Identical Values in Two Columns

Threaded View

  1. #1
    Registered User
    Join Date
    10-04-2017
    Location
    London, England
    MS-Off Ver
    2016
    Posts
    8

    Finding Identical Values in Two Columns

    Hello,


    This time, I have to write a sub that checks if a value is duplicate in two columns. If it is, a message box should appear saying "blah." If it is not, a message box should appear saying "okay."


    I have written a code. However, when I run it, I always get the message box saying "okay." This should not happen because there are definitely identical values in the two columns. Any help fixing my code would be great.
    Sub Compare()
    Dim r1 As Range, r2 As Range, rng1 As Range, rng2 As Range
    Set r1 = Worksheets("Sheet1").Range("A2:A11")
    Set r2 = Worksheets("Sheet1").Range("B2:B11")
        For Each rng1 In r1
              For Each rng2 In r2
                   If rng1 = rng2 Then
                        MsgBox ("blah")
                   Else
                        MsgBox ("okay")
                   End If
              Next
         Next
    End Sub
    Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. Rule #3 requires code tags. I have added them for you this time because you are a new member. --6StringJazzer
    Last edited by 6StringJazzer; 10-06-2017 at 11:15 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Comparing two columns & showing identical values
    By Sham Sundar in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-18-2016, 07:46 AM
  2. Look up identical values in two seperate columns
    By nature718 in forum Excel General
    Replies: 1
    Last Post: 03-20-2014, 06:52 PM
  3. Finding similar but not identical values using COUNT and COUNTIF
    By krixtoffer in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-25-2011, 05:44 AM
  4. Finding similar, but not identical values in two-dimensional datasets
    By krixtoffer in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 10-24-2011, 04:51 PM
  5. Replies: 1
    Last Post: 11-09-2005, 03:00 PM
  6. Replies: 2
    Last Post: 05-17-2005, 01:32 PM
  7. Replies: 0
    Last Post: 05-14-2005, 03:19 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