vba Insert comment for value matches -NFL Teams

gtd526

Well-known Member
Joined
Jul 30, 2013
Messages
675
Office Version
  1. 2019
Platform
  1. Windows
Hello,
If any cell in a range1 is equal to any cell in range2, then insert comment to range1 cell.
Thank you.

NFL.xlsm
ABCD
1Range1
2IND
3DEN
4NYG
5GBRange2
6PITKC
7BUFSF
8LACBUF
9CLEPHI
10HOU
11JAX
12CHI
13TB
14TEN
15WAS
16SF
17CAR
18PHI
19ARZ
20DAL
21LAR
22CIN
23BAL
24LVR
25KC
Test2
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Hello,
If any cell in a range1 is equal to any cell in range2, then insert comment to range1 cell.
Thank you.

NFL.xlsm
ABCD
1Range1
2IND
3DEN
4NYG
5GBRange2
6PITKC
7BUFSF
8LACBUF
9CLEPHI
10HOU
11JAX
12CHI
13TB
14TEN
15WAS
16SF
17CAR
18PHI
19ARZ
20DAL
21LAR
22CIN
23BAL
24LVR
25KC
Test2
I found the code to complete the task.
Range1 and Range2 are on different spreadsheets.

VBA Code:
Sub Add_Comments()
'add comment to specific cell

    Dim rcell As Range
    Dim commentvalue As String
    Dim rng As Range
    
    Sheet1.Range("A4:A35").ClearComments

    For Each rcell In Sheet1.Range("A4:A" & Sheet1.Range("A" & Sheet1.Rows.CountLarge).End(xlUp).Row)
    
        For Each rng In Sheet3.Range("AG3:AG10")
            If rng.Value = rcell Then
                    commentvalue = ("All(-)ATS")
                    rcell.AddComment commentvalue
                Exit For
                End If
            Next rng
    Next
    
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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