Need Assistance- Looking to include a pop up window on my code

Giovanni03

New Member
Joined
May 23, 2023
Messages
33
Office Version
  1. 365
  2. 2021
Platform
  1. 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.

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
 
Do you have formulas in column "D"?

Check the cells, maybe you have blank spaces in the cells.

Also check the values, they may contain blank spaces to the left or right.

Or put a sample of your data here for review. Use the XL2BB tool to paste a minisheet here.

Note XL2BB:
For the future, it would help greatly if you could give us the sample data in a form that we can copy to test with, rather that a picture.
MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in
Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
I was able to get your code to work as well, something silly on my end but both your code and Jow works perfectly. Thank you both
 
Upvote 0

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
That make sense, its counting all of the extra rows that i have on my file. since I have macros buttons and other things my data doesn't actually start till row 12... good ole facepalm moment for myself. it works perfectly now, I used your original code and made it start count range D12
Yep,I figured it was something like that!
So, not only did you get a solution for your question, you also learned a new debugging technique!
:)
 
Upvote 1

Forum statistics

Threads
1,223,909
Messages
6,175,315
Members
452,634
Latest member
cpostell

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