This post will guide you through the process of showing an image on mouseover in one cell in Excel 2013/2016/2019/365. This can be a helpful way to provide additional information or context for data in your spreadsheet.
We will provide step-by-step instructions for adding a pop-up image to a cell when mouse hovers in your worksheet, along with a sample VBA code and comments to help you understand how it works.
Table of Contents
1. Video: Show Image on Mouseover in One Cell
This video will demonstrate how to show an image on mouseover in one cell in Excel using VBA code and cell comment. We will provide clear instructions and a sample VBA code to explain how each step works.
2. Show Image on Mouseover in One Cell by Inserting Cell Comment
If you want to add a pop-up picture to the cell, and when you hover the mouse over the cell, and the picture will appear. You can try to add a picture into the cell comment to achieve the result. Just do the following steps:
Step1: select one cell that you want to insert comment to insert a picture. Such as: B1
Step2: right click on it, and select Insert Comment from the popup menu list. And a comment box should be inserted in cell B1.
Step3: right click the border of the comment, and choose Format Comment… from the popup menu list. And the Format Comment dialog will open.
Step4: switch to the Colors and Lines tab in the Format comment dialog box, and open the Color drop down list and click Fill Effects from the drop down list. And the Fill Effects dialog will open.
Step5: click the Picture tab in the Fill Effect dialog box, and click the Select Picture button to select one picture. It will show the picture preview in the comment. Click Ok button.
Step6: click Ok button to close dialog. And the picture has been inserted into the comment. When you hover over the cell, the picture will show up.
3. Show Image on Mouseover in One Cell with VBA Code
To show an image on mouseover in a cell in Excel, you can use an VBA Code to do it. Here are the steps:
Step1: Insert an image in your Excel worksheet and Change image name as “excelhow_image”
Step2: Right-click on the image and select “Size and Properties” or “Format Picture” from the menu that appears.
Step3: In the “Size and Properties” or “Format Picture” dialog box, select the “Properties” tab. Check the box next to “Don’t move or size with cells” to make sure the image stays in place when you scroll or resize the worksheet.
Step4: Right-click on the worksheet tab and select “View Code“. The VBA editor will open.
Step5: In the VBA editor, paste the following code. Close the VBA editor.
Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim rng As Range Dim shp As Shape Set rng = Range("A1") 'change this to the cell range you want to add the image to Set shp = ActiveSheet.Shapes("excelhow_image") 'change this to the name of your image If Not Intersect(Target, rng) Is Nothing Then With shp .Top = rng.Top .Left = rng.Left .Height = rng.Height .Width = rng.Width .Visible = True End With Else shp.Visible = False End If End SubNote: Replace “A1” with the cell range you want to add the image to and “excelhow_image” with the name of your image in the code.
Step5: when you click on the cell range you specified, the image should appear. when you click any other cells, the image will disappear.
Adding an image that appears on mouseover in one cell can be a useful way to enhance the functionality and visual appeal of your Excel worksheet. With the use of VBA code and a few simple steps, you can easily create this interactive feature that allows users to access additional information or context with just a hover of their mouse.