Help with VBA code for auto filter cells with no highligths

usui

Board Regular
Joined
Apr 20, 2020
Messages
55
Office Version
  1. 2016
  2. 2013
Platform
  1. Windows
Hi,

Can anyone help me with a vba code for auto filtering the cells with no highlights on Columns A & B and result should be on cell E36 separated with comma.
(I am separating the datas with no duplicates "columns A&B")

please see the sample here:
1660847205733.png


I hope someone will be able to help me with this problem. I really appreciate any help I can get.
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
How exactly are these cells being colored?
Is it being done manually or by Conditional Formatting?
If Conditional Formatting, can you show us the exact rule that is doing the formatting?
 
Upvote 0
How exactly are these cells being colored?
Is it being done manually or by Conditional Formatting?
If Conditional Formatting, can you show us the exact rule that is doing the formatting?
Yes from conditional formatting, highlight duplicates..i want to have the datas with no duplicates (column a&b) separated with comma on cell E36
 
Upvote 0
Try this:
VBA Code:
Sub MyNonDups()

    Dim lrA As Long, lrB As Long
    Dim r As Long
    Dim str As String
    
'   Find last row with values in columns A and B
    lrA = Cells(Rows.Count, "A").End(xlUp).Row
    lrB = Cells(Rows.Count, "B").End(xlUp).Row
    
'   Loop through all rows in columns A
    For r = 1 To lrA
'       If no duplicates, add to string
        If Application.WorksheetFunction.CountIf(Range("A:B"), Cells(r, "A")) = 1 Then
            str = str & Cells(r, "A") & ", "
        End If
    Next r
    
'   Loop through all rows in columns B
    For r = 1 To lrB
'       If no duplicates, add to string
        If Application.WorksheetFunction.CountIf(Range("A:B"), Cells(r, "B")) = 1 Then
            str = str & Cells(r, "B") & ", "
        End If
    Next r
    
'   If any values returned, enter to cell E36
    If Len(str) > 0 Then Range("E36") = Left(str, Len(str) - 2)
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,491
Messages
6,125,102
Members
449,205
Latest member
ralemanygarcia

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