Giovanni03
New Member
- Joined
- May 23, 2023
- Messages
- 33
- Office Version
- 365
- 2021
- Platform
- Windows
Hello everyone,
I need some help with my code, I currently have it set so if a number doesn't match on two different sheets then those numbers are highlighted red on sheet 2. I'm trying to improve this and see if its possible to include a pop up window showing the amount that turned red on sheet 2. For example if 3 out of 100 numbers turned red then it can pop up stating "Found 3" or something like that. if none then it can also pop up stating Found 0.
Here's the code i have.
I need some help with my code, I currently have it set so if a number doesn't match on two different sheets then those numbers are highlighted red on sheet 2. I'm trying to improve this and see if its possible to include a pop up window showing the amount that turned red on sheet 2. For example if 3 out of 100 numbers turned red then it can pop up stating "Found 3" or something like that. if none then it can also pop up stating Found 0.
Here's the code i have.
VBA Code:
Option Explicit
Sub highlight()
Dim lr&, r1 As Range, r2 As Range, cell As Range
With Sheets("Sheet 1")
lr = .Cells(Rows.Count, "M").End(xlUp).Row
Set r2 = .Range("M1:M" & lr)
End With
With Sheets("Sheet 2")
lr = .Cells(Rows.Count, "D").End(xlUp).Row
Set r1 = .Range("D1:D" & lr)
For Each cell In r1
If r2.Find(cell.Value) Is Nothing Then cell.Font.Bold = True
If r2.Find(cell.Value) Is Nothing Then cell.Font.Color = vbRed
Next
End With
End Sub