Create a dynamic Excel tooltip based on drop down and cell options.

ExcellyMan

New Member
Joined
Nov 14, 2022
Messages
1
Office Version
  1. 2019
Platform
  1. Windows
Hi there,

First time poster here. I've been asked to design a spreadsheet for work that tracks delays on certain trucks for the days of the week. Under each day, the cell has a drop down option denoting either "On Time", "Delay", or "Cancelled". Here's an example:

TruckMondayTuesdayWednesdayThursday
AOn TimeCancelledOn TimeOn Time
BOn TimeOn TimeDelayDelay
COn TimeDelayOn TimeOn Time

What I'd like is to have a tooltip value show up when I hover over a cell ONLY when "Delay" has been picked from the drop down. Additionally, I want that tooltip value to reference a particular cell elsewhere on the worksheet containing a specific delay reason since not all the cells reading "Delay" will have the same delay codes. So for example, a tooltip value when picking "Delay" for Truck C on Tuesday would show a value of "Traffic" while a tooltip value when picking "Delay" for Truck B on Wednesday may show "Driver got lost". The delay values would be populated elsewhere on the sheet but I would simply be referencing them. I've been scouring the web, trying to look up ways to do this but haven't really found what I'm looking for. If anyone is able to help me in any way I'd greatly appreciate it. Also, if further clarification is needed please let me know and I'd be happy to elaborate further.

Thanks.
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Open the module for the sheet that contains your table (right click on the sheet name tab, then select 'view code')
Paste the following code into the VBA window that opens. Then read through the comments, in particular about the table name or address. Modify to suit then test the code as is.

After you see that it works you need to add some code to get the correct text to add into the comment

VBA Code:
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
    
    If Target.Cells.Count > 1 Then Exit Sub  'ignore if user modifies more then one cell (copy paste of range for instance)
    ' See if the modified cell falls within the table with truck movements.
    ' The table should be given a name , or you can replace 'MyTable'(below) with table address
    If Not Intersect(Target, Range("MyTable")) Is Nothing Then
        With Target
            If .Value Like "Delay" Then 'the modified cell (target) now contains 'Delay'
                .AddComment
                .Comment.Visible = False
                'The text that you want to add to the note, needs to be compiled by you in some additional code
                .Comment.Text Text:="This is note with text"
            Else                        'the modified cell (target) contains other value than 'Delay'
                If Not .Comment Is Nothing Then
                    .Comment.Delete
                End If
            End If
        End With
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,062
Messages
6,122,925
Members
449,094
Latest member
teemeren

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