Hyperlink TO a picture from a cell

minaetdave

New Member
Joined
Sep 7, 2023
Messages
6
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
Hello, I'm trying to get this working in my excel file...
I get a first sheet 'List' + second one 'overview'.

In sheet 'overview', I get few pictures, each of these ones has been renamed picA, picB, picC,...

I would be able from sheet 'list', by double clicking into the cell were I get the name of the picture (PicA,PicB,..) to get selected the related picture in the sheet 'overview'...to help me to identify quickly where is this picture

Is there any way (I think so) to do this easily with VBA?

Thanks!
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Hi, welcome to the forum! You could try this which would go in the "Overview" sheets code module.

VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim s As Shape
On Error Resume Next
Set s = Sheets("Overview").Shapes(Target.Value)
On Error GoTo 0
If Not s Is Nothing Then
    Application.Goto s.TopLeftCell, True
    Cancel = True
End If
End Sub
 
Upvote 0
Hi, welcome to the forum! You could try this which would go in the "Overview" sheets code module.

VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim s As Shape
On Error Resume Next
Set s = Sheets("Overview").Shapes(Target.Value)
On Error GoTo 0
If Not s Is Nothing Then
    Application.Goto s.TopLeftCell, True
    Cancel = True
End If
End Sub

Just tried, I have done:

1- Alt + F11
2- Right click on the 'Overview sheet' > Insert > Module
3- Past your code
4 - Save
5 - Go in 'List' sheet and in cell T7, double click on the cell

BUT once double clicked, I edit the value in the cell (=CHIU1000613).
Checked and in the sheet 'overview', the picture I'd like to get selected is named also 'CHIU1000613'

It can be possible to get anything else than double click, no matter for me :)
 
Upvote 0
2- Right click on the 'Overview sheet' > Insert > Module
Sorry, my instructions were not correct. Right click the "List" sheet, choose "View Code" and paste the code there. Not in a standard code module.
1694085077120.png
 
Upvote 0
Sorry, my instructions were not correct. Right click the "List" sheet, choose "View Code" and paste the code there. Not in a standard code module.
View attachment 98378
Well like this working..or almost :)
Isn't it possible to get the picture 'selected' because with this code, once double clicked, I am redirected to the 'overview sheet' and get the picture expected on the top upper corner.

My 'overview' sheet is like a map with several pictures and idea to get it selected in order to locate it quickly...
 
Upvote 0
Isn't it possible to get the picture 'selected'
Hi, you could try like this.
VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim s As Shape
On Error Resume Next
Set s = Sheets("Overview").Shapes(Target.Value)
On Error GoTo 0
If Not s Is Nothing Then
    Application.Goto Sheets("Overview").Range("A1")
    s.Select
    Cancel = True
End If
End Sub
 
Upvote 0
Solution
P
Hi, you could try like this.
VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim s As Shape
On Error Resume Next
Set s = Sheets("Overview").Shapes(Target.Value)
On Error GoTo 0
If Not s Is Nothing Then
    Application.Goto Sheets("Overview").Range("A1")
    s.Select
    Cancel = True
End If
End Sub
Perfect!!!!!

Exactly what I want

Thank you so much!!!!
 
Upvote 0
Hi, you could try like this.
VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim s As Shape
On Error Resume Next
Set s = Sheets("Overview").Shapes(Target.Value)
On Error GoTo 0
If Not s Is Nothing Then
    Application.Goto Sheets("Overview").Range("A1")
    s.Select
    Cancel = True
End If
End Sub

Hello,

I'm back for a small request... Can we adapt the code in order to allow only the double click in column C?
With this code, if double click in column C works perfect but on the other cells, it show me wrong picture

Thanks in advance 👍
 
Upvote 0
Can we adapt the code in order to allow only the double click in column C?
Hi, you can try this small modification.

VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim s As Shape
If Target.Column = 3 Then
    On Error Resume Next
    Set s = Sheets("Overview").Shapes(Target.Value)
    On Error GoTo 0
    If Not s Is Nothing Then
        Application.Goto Sheets("Overview").Range("A1")
        s.Select
        Cancel = True
    End If
End If
End Sub
 
Upvote 0
Hi, you can try this small modification.

VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim s As Shape
If Target.Column = 3 Then
    On Error Resume Next
    Set s = Sheets("Overview").Shapes(Target.Value)
    On Error GoTo 0
    If Not s Is Nothing Then
        Application.Goto Sheets("Overview").Range("A1")
        s.Select
        Cancel = True
    End If
End If
End Sub
Perfect!!!!
 
Upvote 0

Forum statistics

Threads
1,223,238
Messages
6,170,939
Members
452,368
Latest member
jayp2104

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