VBA Function to Highlight MATCHES

Haziyama

New Member
Joined
Aug 28, 2020
Messages
1
Office Version
  1. 2013
Platform
  1. Windows
Hello everyone,
It has been a week since I am looking to do a function which highlights all matches between two different sheets.
It compares from a value from the first one to whole column from the second and it highlights the match in the first one.
I am still new to coding in VBA and I got confused how to do it by myself.
So can any one help me doing this, please?

Here is my code until now:


Sub searching ()
LastL = ActiveSheet.UsedRange.Rows.Count
CurrentL = 2

While CurrentL <= LastL
If Worksheets("HP").Range("C" & CurrentL).Value = Worksheets("Client non connectés").Range("B:B").Value Then
Worksheets("Client non connectés").Range("B" & CurrentL).Interior.Color = 65535
End If
CurrentL = CurrentL + 1



'Wend
End sub
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Hi & welcome to MrExcel.
How about
VBA Code:
Sub Haziyama()
   Dim Cl As Range
   Dim Dic As Object
   
   Set Dic = CreateObject("scripting.dictionary")
   Dic.CompareMode = 1
   With Sheets("HP")
      For Each Cl In .Range("C2", .Range("C" & Rows.count).End(xlUp))
         Dic.Item(Cl.Value) = Empty
      Next Cl
   End With
   With Sheets("Client non connectés")
      For Each Cl In .Range("B2", .Range("B" & Rows.count).End(xlUp))
         If Dic.Exists(Cl.Value) Then Cl.Interior.Color = 65535
      Next Cl
   End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,947
Messages
6,122,411
Members
449,081
Latest member
JAMES KECULAH

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