Counting multiple cells with different text (Mismatch)

JODomingos

New Member
Joined
Jul 11, 2020
Messages
48
Office Version
  1. 2016
Platform
  1. Windows
Hi Friends.
Can you help me to create a macro to count cells that are different between two rows.

For instance:
In column B I have multiple cells that are duplicated, I would like to compair all the duplicates for every column and get the number of mismatch. Yellow cells should be counted as mismatch.

I would like consider only the strings ( AA , CC , GG , TT).


1601060545966.png
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Not a macro, but here's a formula that seems to work:

Book1
ABCDEFG
110K1020710K0090510K0090610K13207
21111
3Name7151407158337931861022873
4942AATTGGAA2
5942GGTTGGGG2
6991AATTGGGG1
7991TTGTAGCG1
8!17IICC37018AATTGGCC1
9!17IICC37018AATTGGGG1
10!17IITT13034AACCGGCC1
11!17IITT13034AATTGGCC1
Sheet9
Cell Formulas
RangeFormula
G4:G11G4=SUMPRODUCT(--(MMULT({1,1,1,1},SIGN(COUNTIFS($B:$B,$B4,OFFSET(C:C,0,COLUMN(C:F)-COLUMN(C:C)),{"AA";"CC";"GG";"TT"})))>1))
 
Upvote 0
You can never have too may solutions. Now I haven't found a combination that doesn't work but if you do let us know.


VBA Code:
Sub Unique1()

Dim row1 As Long
Dim col1 As Long
Dim LastRow As Long
Dim cont1

cont1 = 0

LastRow = Cells(Rows.Count, "B").End(xlUp).Row

For row1 = 4 To LastRow Step 2

    For col1 = 3 To 6

        If Not (Cells(row1, col1).Value Like Cells(row1 + 1, col1).Value) Then

            If ((Cells(row1, col1) = "AA" Or Cells(row1, col1) = "CC" Or Cells(row1, col1) = "GG" Or Cells(row1, col1) = "TT") _
            And (Cells(row1 + 1, col1) = "AA" Or Cells(row1 + 1, col1) = "CC" Or Cells(row1 + 1, col1) = "GG" Or Cells(row1 + 1, col1) = "TT")) Then

            cont1 = cont1 + 1
            End If

        End If

    Next col1
Cells(row1, col1) = cont1
cont1 = 0
Next row1

Range("B2").Select
End Sub


20-09-25 unique Rev A.xlsm
ABCDEFGHIJK
110K1020710K0090510K0090610K13207
21111 strings ( AA , CC , GG , TT).
3Name7151407158337931861022873Yellow Cells
4942AATTGGAA2
5942GGTTGGGG
6991AATTGGGG1
7991TTGTGGCG
8!17IICC37018AATTGGCC1
9!17IICC37018AATTGGGG
10!17IITT13034AACCGGCC1
11!17IITT13034AATTGGCC
Unique Count
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,731
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top