PDA

View Full Version : Bring picture to front



BrianDove32
08-11-2018, 01:55 PM
I have a VBA code I have inserted so that when I click on the cell an image is located, the image is enlarged (250x250), and when I click on the cell to the left of the cell the image is located, it's size is reduced (80x80). However, I would like to add a command that when the image is enlarged, it is BROUGHT FORWARD of the all the other images.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'UpdatebyEntendoffice20161111
Application.ScreenUpdating = False
Dim xRg As Range, sPic As Shape
For Each sPic In ActiveSheet.Shapes
If Target.Column > 5 Then
Set xRg = Target.Offset(, 0)
With sPic
If TypeName(.OLEFormat.Object) = "Picture" Then
If .TopLeftCell.Address = xRg.Address Then
.Height = 350
.Width = 350
End If
End If
End With
ElseIf Target.Column = 5 Then
With sPic
If TypeName(.OLEFormat.Object) = "Picture" Then
.Height = 80
.Width = 80
End If
End With
End If
Next sPic
Application.ScreenUpdating = True
End Sub

22705

p45cal
08-11-2018, 02:08 PM
Add .ZOrder msoBringToFront
to:

.Height = 350
.Width = 350
.ZOrder msoBringToFront 'add
Maybe do the same further down in the code too, but it may not be needed.