Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, and 2013. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: ScreenTip for an Image.

ScreenTip for an Image

Written by Allen Wyatt (last updated March 4, 2021)
This tip applies to Excel 2007, 2010, and 2013


7

Eddie has added a small graphic image to a worksheet and tied a macro to the image. When the image is clicked, the macro is executed. Eddie wonders if it is possible to add a label or comment to the image so that when a user hovers the mouse pointer over the image, the label/comment appears and tells the user what the macro does.

You might at first think that you could add a ScreenTip to the image, but that can only be done if you assign a hyperlink to it. Adding the hyperlink (and ScreenTip) is easy enough, but you'll find that the hyperlink takes precedence over the macro, stopping it from being run.

This means that you need to look for other ways to tackle the problem. Unfortunately there is no easy way to create this type of ScreenTip, but there are a couple of ways you can approach the task. One thing you can do is to add a command button to the worksheet, and then assign the image to the button. The whole image then serves as a button. When you click the button, it executes the CommandButton1_Click event handler (assuming you use the default name for the command button).

Next you need to create a text box that approximates what a ScreenTip looks like. Actually the text box gives you more latitude than you have with a regular ScreenTip, because it can be formatted in any manner you desire, and it can contain any explanatory text you desire. All you need to do is make sure that the text box is given a unique name, such as "MyShape". (You assign a name to the text box by selecting it and then changing the name in Name box in the upper-left corner of the worksheet area.)

With the command button and text box in place, right-click on the command button and choose to display the code window for the command button. Then, add the following code to the code window:

Private Sub CommandButton1_Click()
    'Call your regular macro here
    Hide_Shape
End Sub
Private Sub CommandButton1_MouseMove( _
    ByVal Button As Integer, ByVal Shift As Integer, _
    ByVal X As Single, ByVal Y As Single)
    Display_and_Hide_Shape
End Sub

It is the Click event handler that you will need to modify to call your normal macro code. The MouseMove code is executed when the mouse is moved over the command button. In this case, the code displays the text box you created.

Next, insert the following macros into a standard macro module. These two macros show and hide the text box shape that you created. Note that the first macro uses the OnTime method to automatically hide the shape two seconds after it is first displayed.

Sub Display_and_Hide_Shape()
    ActiveSheet.Shapes("MyShape").Visible = True
'   adjust time
    Application.OnTime Now + TimeValue("00:00:02"), "Hide_Shape"
End Sub
Sub Hide_Shape()
    ActiveSheet.Shapes("MyShape").Visible = False
End Sub

With all the macros in place, just move the mouse pointer over the command button image. The text box should disappear two seconds later, only to reappear when you again move the mouse over the image.

Another approach is to embed the picture in a chart object, name the picture using whatever text you want to appear in the ScreenTip, and then assign the macro to the chart object. This may sound a bit confusing, but it is relatively easy to do by following these general steps:

  1. Create a blank chart object. You can do this by simply selecting a blank cell, choosing to insert a chart, and immediately clicking the Finish button. The chart won't contain anything, which is why it is a "blank chart object."
  2. Next add the picture to the chart object. Just copy the picture to the Clipboard and then select the blank chart object (you created it in step 1) and paste the contents of the Clipboard.
  3. Adjust the size of both the chart object and the picture within the chart object so that they represent your needs.
  4. Select the picture within the chart object, and then give the picture a name by changing whatever is in the Name box at the upper-left corner of the worksheet area. This name should be the text you want to appear as your ScreenTip.
  5. Now assign your macro to the chart object (not the picture within the chart object) by right-clicking the chart object and choosing Assign Macro.

That's it. Now, when you move the mouse pointer over the image, the name of the image appears as a ScreenTip, and if you click then the macro assigned to the chart object is executed.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (724) applies to Microsoft Excel 2007, 2010, and 2013. You can find a version of this tip for the older menu interface of Excel here: ScreenTip for an Image.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Finding a Change in Typeface

When you format a document, you can go so far as to change the font of each character in the document. This may be ...

Discover More

Getting Rid of Spaces in Merged Data

When you merge information with a Word document, you may not be completely satisfied with the appearance of some of the ...

Discover More

Graphics Marked as Changed when Comparing Documents

The tools on the Review tab of the ribbon allow you to do all sorts of markup and comparisons of documents. When ...

Discover More

Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!

More ExcelTips (ribbon)

Converting a Range of URLs to Hyperlinks

Converting a single URL into a hyperlink is easy. Converting hundreds or thousands can be much harder if you have to rely ...

Discover More

Hyperlinks No Longer Work in a Workbook

Hyperlinks can be a great timesaver and very convenient. Unless, of course, if they don't work as you expect. This tip ...

Discover More

Retrieving Web Query Data without Interruption

If you use Excel's Web Query tools to grab data from a website, you may run into some problems if the site isn't ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 6 + 5?

2019-12-07 09:48:27

Simon

The only slight problem I've had using the Chart method is that after clicking the link the screentip will not go away.


2018-03-05 08:40:19

Chris Sandiford

Just found this two years on and found it very useful. You didn't explain how to attach the image to the command button though, but I found that in Properties. One thing you cannot do however, is remove borders form the Command Box so if you want a true representation of your image, it doesn't work 100%.

However, if you use a Label, the same workaround principle applies and you can use a transparent background so that worked for me!


2016-01-22 11:04:20

Simon

Very nice. Simple and works a treat.


2015-04-21 08:41:16

Glenn Case

Allen:

Thanks for this tip. I have been approximating ScreenTips using Data Validation, but I like this approach a lot better. Keep up the good work!


2015-04-20 14:58:51

Luis G Rodriguez

I found the same problem, but I've found a workaround (Excel 2010).

1.- Create the button/object -outside- the chart, just on the spreadsheet.

2.- Now, - select the picture and then give the picture a name by changing whatever is in the Name box at the upper-left corner of the worksheet area. This name should be the text you want to appear as your ScreenTip you want the text to appear when the button is moused over..

3.- Create a blank chart object

4.- Select button/object on the spreadsheet and copy or cut it

5.- Now, select the blank chart object

6.- Hit Ctrl+V

This way the object renamed outside of the chart will appear inside it, with the object name you gave to it before.

7.- Now assign your macro to the chart object (not the picture within the chart object) by right-clicking the chart object and choosing Assign Macro.


2015-04-20 03:38:07

Des Lavender

Although I managed to click on the picture within the chart object the renaming didn't take after typing it and pressing "Enter" - remaining as "Picture 1"


2015-04-19 07:47:33

Ioannis Nikolopoulos

Dear Allen, I didn't find a way to change the name of the picture at the upper-left corner of the worksheet area, as described in step #4. The name of the picture remains the same: "chart".
Did I miss something? Please help!


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.