Loop through images using VBA

mattw92

New Member
Joined
Jun 21, 2011
Messages
1
This is my first post but I have found lots of answers over the past year through Google searches which have linked back to this site/forum. I've spent countless hours trying to solve a current problem and can't find my answer, so hoping someone can help.

I have a worksheet (Excel 2007) that has many rows of projects listed. In one cell, I want to put a pie chart that will indicate the progress of each project - 0%, 25%, 50%, 75%, 100% completed. In a perfect world, I'd click on the chart and it would change from 0 to 25, another click would change 25 to 50, etc. Clicking on 100 would change it back to 0 as a method of resetting the chart.

It's a little clunky, but my latest thought was to create 5 JPEGs, import them and layer them one on another (using the send to back method to show the next % chart). I named each one Comp0, Comp25, and so on. Using Application.Caller and ZOrderPosition, it works perfectly except that I will have many rows of these charts and they have the same image name (so I'll have many Comp0, Comp25, etc. images on the worksheet). Because I'm using the Application.Caller method, it is linking to the wrong group of images and changing another row's charts.

Any thoughts on how I can make this work? Is there another way to send to back without having to use the name of the image I clicked on, so it can't link to a different chart elsewhere on the sheet? I know that I can right-click on the image and send-to-back, but I'd like to keep it simple since there are many people throughout the company that will be using this.

I appreciate any help you can give. Thanks!
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Forum statistics

Threads
1,224,599
Messages
6,179,831
Members
452,946
Latest member
JoseDavid

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