Help w/ show/hide on click function for vba?

jdlev

New Member
Joined
Jan 6, 2017
Messages
27
Hi Guys,

Trying to click on a thumbnail of an image to reveal a full size image in a static position on the worksheet. The row on the left is a thumbnail of the full size picture on the right. What's the best method? Should I use a show/hide property for the larger picture or should the thumbnails be a reduced version of the larger image? By default, I'd want an image shown at all times, so I assume I'd have to have 2 separate images of each picture - one thumbnail and one full size?

So basically, just need to assign a macro to a picture to show and hide a larger version of the same image. Here's an example of what I'm talking about:

39848472952_043ecfb7b2_z.jpg
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Actually....scratch that...an easier option would just be to move the picture to the front rather than show/hide it. So, how would I go about making a more efficient script.

I basically have the small images on the left named "thumbnail1...5" and the larger images on the right named "fullsize1...5"...how could I shorten the script so I can use the same macro for all 5 buttons?
 
Upvote 0
Here's what I came up with on my own. It works, but it's by no means elegant...

Sub picToFront1_click()
ActiveSheet.Pictures("fullsize1").Select
Selection.ShapeRange.ZOrder (msoBringToFront)
End Sub


Sub picToFront2_click()
ActiveSheet.Pictures("fullsize2").Select
Selection.ShapeRange.ZOrder (msoBringToFront)
End Sub


Sub picToFront3_click()
ActiveSheet.Pictures("fullsize3").Select
Selection.ShapeRange.ZOrder (msoBringToFront)
End Sub


Sub picToFront4_click()
ActiveSheet.Pictures("fullsize4").Select
Selection.ShapeRange.ZOrder (msoBringToFront)
End Sub


Sub picToFront5_click()
ActiveSheet.Pictures("fullsize5").Select
Selection.ShapeRange.ZOrder (msoBringToFront)
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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