Forum

Notifications
Clear all

[Solved] Tool-tip like Comments

3 Posts
3 Users
0 Reactions
276 Views
(@waq_786)
Posts: 1
New Member
Topic starter
 

Scenario:
I have a cell (let's say A1) with a drop-down list of three data validation options (Excellent, Good, and Poor) formatted with conditional formatting to display different colors based on the selected options from the drop-down list.

For the purpose of sharing the additional info for the readers (other than the author), I want to add comment to each of these options separately.

Requirement:
a) The specific comments to each of the data validation options should not be displayed in another cell.

b) The info (of the comment box) should pop-up/display when the relevant option is selected from the drop-down list ONLY when the cursor is hovered over the selected option. It should behave like a tooltip comment.

Question: Is it possible to add comments with each of the drop-down options separately in a single cell (A1)?

 
Posted : 08/12/2024 8:16 am
Anders Sehlstedt
(@sehlsan)
Posts: 972
Prominent Member
 

Hello,

It is possible with VBA, as I am not using VBA myself I am not able to write some code for you. Added below is the answer from one of the AI tools.

-----

Here's a streamlined version of the steps:

1. **Set Up Your Drop-Down List**:
- Select cell A1.
- Go to `Data` > `Data Validation`.
- In the `Data Validation` window, choose `List` from the `Allow` drop-down menu.
- In the `Source` box, type `Excellent,Good,Poor` and click `OK`.

2. **Apply Conditional Formatting**:
- Select cell A1.
- Go to `Home` > `Conditional Formatting` > `New Rule`.
- Choose `Use a formula to determine which cells to format`.
- Enter the formula `=A1="Excellent"` and set the desired formatting for "Excellent" (e.g., green fill).
- Repeat the steps above for "Good" (e.g., yellow fill) and "Poor" (e.g., red fill).

3. **Insert VBA Code**:
- Press `Alt + F11` to open the VBA editor.
- In the VBA editor, go to `Insert` > `Module` and paste the following code:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("A1")) Is Nothing Then
If Target.Value = "Excellent" Then
MsgBox "Excellent: This is the highest rating, indicating outstanding performance."
ElseIf Target.Value = "Good" Then
MsgBox "Good: This is a satisfactory rating, indicating good performance."
ElseIf Target.Value = "Poor" Then
MsgBox "Poor: This is the lowest rating, indicating performance that needs improvement."
End If
End If
End Sub

- Close the VBA editor.

With these steps, the comments will display as message boxes when you select an option from the drop-down list in cell A1.

-----

As mentioned, the above example is the result from an AI tool, I have not tested it myself.

Br,
Anders

 
Posted : 10/12/2024 5:07 pm
(@kjbox)
Posts: 69
Trusted Member
 

This will add a comment to cell A1 when its value changes via cell validation, rather than using a message box.

The comment will become visible when you hover over A1.

Sample file attached.

Code:

Private Sub Worksheet_Change(ByVal Target As Range)
    Const sE$ = "Excellent: This is the highest rating, indicating outstanding performance."
    Const sG$ = "Good: This is a satisfactory rating, indicating good performance."
    Const sP$ = "Poor: This is the lowest rating, indicating performance that needs improvement."

    If Not Intersect(Target, [a1]) Is Nothing Then
       Target.ClearComments
        If Target = "Excellent" Then Target.AddComment sE
        If Target = "Good" Then Target.AddComment sG
        If Target = "Poor" Then Target.AddComment sP
    End If

End Sub

You can change the comment text to suit by changing the values of the 3 Const variables.

Note the code must be placed in the Sheet Object module for the sheet that has the data validation, not in a standard module.

 
Posted : 11/12/2024 6:02 am
Share: