Excel can I link to a picture in another sheet, same worksheet?

jkanderson

New Member
Joined
Oct 4, 2020
Messages
8
Office Version
  1. 2013
Platform
  1. Windows
I know I can put pictures in an Excel comment.
Sometimes I want to use the same picture on several different sheets in the same workbook.
I want the picture to popup on hover over like a picture in a comment does.
Is there any way for the comment to link to (and show) the picture by hyperlink?
I want to keep filesize down and rather than insert the same picture 3 and 4 times on different sheets I am hoping a comment can link to the (one) original picture on the sheet
If this can be done how can I do it?
 
Can I send you a simple 10 row or so example of what I am trying to do? Perhaps an example of members of Britain's Royal Family? That would make things a little easier to follow
The tool to use is provided on this site. It enables you to upload a sample range very easily.
 
Upvote 0

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Not sure I understand the sample range. My worksheet has the sheet of names, this is the main one. Each name contains a comment with fastc of the person. In the cell just to the left of the name cell is a comment with picture only. No code put in yet.

The light bulb did come for the picture sheet, as I don't need one. Once a picture in a comment is in a cell on the name page, I can just copy and paste the comment wherever I want as many times I want.

QVic pic (actual photo in a comment) - Queen Victoria (text facts in a comment) - Vic's father Prince Edward (text facts in a comment) - Vic's mom Victoria (text facts in a comment - the next two cells to the right of the parents (not shown here) will each have a comment copied picture in a comment

The problem I see is file size. With just a few names there is no issue. With several hundred, there might be. Unless, can the code copy the comment to another cell "on the fly"? That is, copy right on mousein (or mouseover). Then delete on mouseout. If I want to go back and look at it again, then of course it would require another copy to the cell when I mouseiover All the names of the people will have the actual picture in a comment. It is the pictures of the parents and perhaps the kids that will have a copied picture in a comment.

Q.Vic.picQueen VictoriaPrince Edward (Duke of Kent)Princess Victoria of Saxe-Coburg-Saalfeld
 
Upvote 0
Have you tested code provided in post#10?
 
Upvote 0
Tried to, but as I am very new to this, I can't seem to get the macro named. Does the "VBA Code" at the very beginning of the code in Post 10 also go into the copy and paste to the module?
 
Upvote 0
Have you tested code provided in post#10?
Tried to, but as I am very new to this, I can't seem to get the macro named. Does the "VBA Code" at the very beginning of the code in Post 10 also go into the copy and paste to the module?

Try in a NEW workbook
- install the code as instructed below
- insert a comment in last visible row in column A in Sheet1
- double click on same cell to hide comment
- right-click on same cell to make comment visible

The code
The code must be placed in the sheet module (it will not work if placed anywhere else anywhere else)
- right-click on Sheet1 name tab \ select View Code \ paste code into that window

VBA Code:
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
    On Error Resume Next
    With Target
        If Not .Comment Is Nothing Then
            Cancel = True
            Application.ScreenUpdating = False
            With .Comment
                .Visible = True
                .Shape.Top = ActiveWindow.VisibleRange.Top + 10
                .Shape.Left = Target.Offset(, 2).Left
            End With
        End If
    End With
    On Error GoTo 0
End Sub

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    On Error Resume Next
    Cancel = True
    Target.Comment.Visible = False
    On Error GoTo 0
End Sub
 
Upvote 0
I was following a link I found on the web for beginners to insert code into Excel. It didn't mention anything at all about right-clicking on the sheet/name tab to bring up the module. So I am glad you included this, very helpful! I took Basic many years ago, and tried html so know a little about coding, but not enough for something like this. After I copied and pasted the code into the module (my new worksheet has only the one sheet) don't I have to save the worksheet before going any further? The link said to save as macro-enabled worksheet then to name the macro then Control/S. That was confusing -
 
Upvote 0
When a workbook contains macros it must in future be saved as macro enabled (and will have extension .xlsm instead of .xlsx)

Did the code in post#15 work for you ?
 
Upvote 0
Sorry, I thought I posted that the code did work. I copy/pasted, went back to sheet 1 to try it.

The hover-over still popped up the comment as I hadn't saved the workbook yet.

Then I right double clicked and the comment popped up two columns over at the top of the sheet and it stayed there.
A left double click made it disappear.

So the code works so far.

But what I am getting at;
1. I can save the sheet by clicking on the normal file/save
2. Then I choose as macro enabled and it does have the extension of .xlsm.
3. After that things get fuzzy.
4. Double clicking on the xlsm sheet comment does nothing.
5. Don't I also have to name the macro while still in the view source module?
6. If not how does the code know to run?
 
Upvote 0

Forum statistics

Threads
1,215,044
Messages
6,122,827
Members
449,096
Latest member
Erald

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