Compare of two column

Closed
dev_raghav1982 Posts 1 Registration date Sunday June 25, 2017 Status Member Last seen June 25, 2017 - Jun 25, 2017 at 02:56 AM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - Jun 27, 2017 at 11:20 AM
I have 2 columns column a have unique record in repetition and in column b I have non unique values ...now what I want ...I want to place the remarks in column c as mix or non mix
example
A. B. C
Ram 1
Ram 2
Ram 1
Suresh. 1
Suresh. 1

1 response

TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 555
Jun 27, 2017 at 11:20 AM
Hi dev_raghav1982,

Give the following code a try and do comment on the result:
Sub RunMe()
Dim mValue As String
Dim x, y, mVar As Integer
Dim Mix As Boolean

x = 2

Do
    mValue = Range("A" & x).Value
    mVar = Range("B" & x).Value
    y = x
    
    Do While Range("A" & x) = mValue
        If mVar <> Range("B" & x).Value Then
            Mix = True
        End If
        x = x + 1
    Loop

    If Mix = True Then
        Range(Cells(y, "C"), Cells(x - 1, "C")).Value = "Mix"
    Else
        Range(Cells(y, "C"), Cells(x - 1, "C")).Value = "Non Mix"
    End If
    
    Mix = False
    
Loop Until Range("A" & x) = vbNullString
End Sub


Best regards,
Trowa
0