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

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
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,215,102
Messages
6,123,099
Members
449,096
Latest member
provoking

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