Formula based values in comment

Bram1212

New Member
Joined
Apr 12, 2018
Messages
36
Hi!

I was wondering if it is possible to show the result of a formula in the comment section. Based on what product ID is showed in B4 I would like to show the result of an VLOOKUP function in the comment section of C4.

Thanking you in advance for any tips!
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
I am using the 2016 version. Looking for a solution in the 'notes' section.

Any idea on what VBA I should use? Got no clue where to start even.

Thanks for reaching out.
 
Upvote 0
Excel object = "Note" ... VBA object = "Comment" - thank you Microsoft :confused::confused:

Place code in sheet module of comment sheet
- right click sheet tab \ View Code \ paste into code window \ back to Excel with {ALT}{F11}
- save workbook as macro enabled

Let me know if you need help modifying code to apply to more than one cell

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim Rng As Range, aComment As String
    With Target
        If .Address(0, 0) = "B4" Then
            Set Rng = Sheets("Other Sheet").Range("A:C")
            aComment = WorksheetFunction.VLookup(Target, Rng, 2, 0)
            On Error Resume Next
            With .Offset(, 1)
                .ClearComments
                .AddComment
                .Comment.Visible = False
                .Comment.Text Text:=aComment
            End With
        End If
    End With
End Sub

Excel 2016 (Windows) 32 bit
A
B
C
3
4
ID-005the "Note" in cell C4 is amended whenever B4 changes
5
Sheet: Comment Sheet

Excel 2016 (Windows) 32 bit
A
B
C
1
Product IDDescriptionType
2
ID-001CatFeline
3
ID-002DogCanine
4
ID-003MouseRodent
5
ID-004LionFeline
6
ID-005TigerFeline
7
Sheet: Other Sheet
 
Last edited:
Upvote 0
Hi Yongle,

Thanks for this solution. It seems to work!

I would like to use this function for a longer list of product ID's in column B. How would I amend the code to apply it on other values in B4, B5, B6, B7 etc and show the vlookup value in the note in C4, C5, C6, C7 etc.
 
Upvote 0
try this ...

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim Rng As Range, aComment As String
        If Not Intersect(Target, Range("B4").Resize(Rows.Count - 3)) Is Nothing Then
            Set Rng = Sheets("Other Sheet").Range("A:C")
            aComment = WorksheetFunction.VLookup(Target, Rng, 2, 0)
            On Error Resume Next
            With Target.Offset(, 1)
                .ClearComments
                .AddComment
                .Comment.Visible = False
                .Comment.Text Text:=aComment
            End With
        End If
End Sub
 
Upvote 0
It seems to work in my small test sheet. I will apply it to the larger sheet later today.

Many thanks for your help!
 
Upvote 0
Hi Yongle,

It works, this is exactly what I was looking for, awesome!

Not sure if I should open a new thread for this, but do you also know a workaround for the red triangles in the cells with a note? Would like to not have them in the sheet since the make the view very chaotic. The standard 'hide note' function in excels makes them go away but also hides the note itself.

Many thanks if you are able to help again.
 
Upvote 0

Forum statistics

Threads
1,215,056
Messages
6,122,907
Members
449,096
Latest member
dbomb1414

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