VBAHelpNeededPlease
New Member
- Joined
- Jun 8, 2020
- Messages
- 10
- Office Version
- 365
- Platform
- Windows
Hi there,
I have the following function that will display a picture if you run your mouse over it. It's quite neat, and works well. However, I'd like to change it from running your mouse over it, to a double click function.
Below is the code that works that will show a picture when you run a mouse over a cell:
And I know I need the below code, of sorts, that if you double click on it something will happen:
I just can't seem to merge the two - so that I get the functionality of the original code, but with needing a double click rather than just passing the mouse over the cell.
Would be a big help if I could get a hand with this.
Thanks,
I have the following function that will display a picture if you run your mouse over it. It's quite neat, and works well. However, I'd like to change it from running your mouse over it, to a double click function.
Below is the code that works that will show a picture when you run a mouse over a cell:
VBA Code:
Dim DoOnce As Boolean
Public Function OnMouseOver(URL As String, TheCell As Range)
DoOnce = True
With ActiveSheet.Pictures.Insert(URL)
With .ShapeRange
.LockAspectRatio = msoTrue
.Width = 570
.Height = 380
End With
.Left = Cells(TheCell.Row, TheCell.Column + 1).Left
.Top = Cells(TheCell.Row, TheCell.Column + 1).Top
.Placement = 1
.PrintObject = True
End With
End Function
And I know I need the below code, of sorts, that if you double click on it something will happen:
VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Target.Address = "$A$1" Then
'do something
End If
Cancel = True
End Sub
I just can't seem to merge the two - so that I get the functionality of the original code, but with needing a double click rather than just passing the mouse over the cell.
Would be a big help if I could get a hand with this.
Thanks,