Drop down Vlookup to display embedded image in fixed location (via mouse rollover)

Discostu

New Member
Joined
Sep 2, 2018
Messages
2
I've been reading up on a solution to this mouse rollover problem. I've found bits of the solution on various sites, but nothing that ties my needs together. Basically, I have a drop-down list of various exercises on Sheet1. Upon hovering over the selected exercise (ie. squat), I need a VLookup function to find "squat" in a table of all exercises on Sheet2. This table has an embedded image of each exercise in the same row as the exercise name. The embedded image of the "squat" would be displayed on Sheet1 upon mouse hover.
The image could be displayed as a comment, or in a fixed location on the sheet (I can make either display option work). The last thing I need is for the image to go away on it's own (I prefer not to use the moat option, a timer could work fine. I should be able to figure this part out).

I just can't seem to find a drop down list mouse rollover Vlookup that inserts an image from a different Worksheet.

Any suggestions or links would be appreciated (I've gone through a few Chandoo posts; as well as several mouse hover applications (Bruce Springstein, Periodic Table, Drawing in Excel, to name a few). Thank you!
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
This suggestion is very simple to replicate, not quite what you requested, but may be a good starting point for you
- image in userform changes when user hovers over each exercise name in a listbox

Images are loaded from a folder (not from a worksheet) - but see final comment below

I found some code here (see post10) and simply added a ListBox click event to triger the image to change
- tested with Excel 2016

To replicate
- create a new workbook (use only sheet1)
- copy a few sample images ( .jpg files) into a single folder
- rename those images to the name of each exercise
- enter names of exercises in cells A1:A12 (they need to be the same as image file names)
- add a userform with a listbox (Listbox1) and image control (Image1)
- paste code below into userform module
- amend fPath value to the path to your images (ensure path separator is added at the end)
- add a button to your sheet to initiate userform with code UserForm1.Show

Code:
Option Explicit
[COLOR=#006400][I]'credit for code below
'https://www.excelforum.com/excel-programming-vba-macros/778834-highlight-item-in-listbox-with-mouseover.html [/I][/COLOR][COLOR=#006400][I] (see post 10)[/I][/COLOR]
    Private m_lngListItemCount As Long
    Private m_dblListItemSize As Double

Private Sub ListBox1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single, ByVal Y As Single)
    Dim lngItem As Long
    lngItem = Application.WorksheetFunction.RoundDown(Y / m_dblListItemSize, 0) + ListBox1.TopIndex
    If lngItem >= ListBox1.ListCount Then lngItem = ListBox1.ListCount - 1
    ListBox1.ListIndex = lngItem
End Sub

Private Sub UserForm_Initialize()
    ListBox1.RowSource = "A1:A13"       'last cell in range is deliberately left empty
    ListBox1.TopIndex = ListBox1.ListCount - 1
    m_lngListItemCount = ListBox1.ListCount - ListBox1.TopIndex
    m_dblListItemSize = ListBox1.Height / m_lngListItemCount
End Sub
[COLOR=#006400][I]'code below added by me[/I][/COLOR]
Private Sub ListBox1_Click()
    Const fPath = "C:\Full Path\To Images\End with Path Separator[COLOR=#ff0000]\[/COLOR]"
    On Error Resume Next
    Image1.Picture = LoadPicture(fPath & ListBox1.Value & ".jpg")
    If Err.Number > 0 Then Image1.Picture = LoadPicture(fPath & "Blank" & ".jpg")
    On Error GoTo 0
End Sub

Further development
- image path and file name could be easily derived via a lookup table if required
- it would be possible to utilise images stored in a worksheet, but is more complicated
 
Last edited:
Upvote 0
I forgot to mention that I added a blank image to display when no other image found (not required but may be useful)
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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