VBA - manipulate Collection of shapes

D4rwin

Board Regular
Joined
Mar 31, 2014
Messages
91
Hi,
I have a sheet with several shapes (100+) and I need to manipulate the transparency of each shape based on the text in each shape.
Currently I am using a For Loop to go through each shape to test if the text equals a specific string. If so, the shape transparency is modified.
However, I suspect that this is quite a cumbersome operation for VBA as it takes a few seconds to process each shape during the loop. I am wondering if it: a) is possible to add each shape matching the text criteria to a collection, and b) is possible to manipulate the shape transparency of each shape in the collection in order to speed it up.

Eventhough the following code will not work, it demonstrates what I'm trying to achieve:

Code:
dim shp as shape
dim colShapes as new collection

for each shp in activesheet.shapes
     if shp.textframe2.textrange.text = "string" then
          colShapes.add shp
     end if
next shp

colShapes.fill.transparency = 0.8

Again, the purpose is to speed up the processing time so that VBA will apply the transparency modification in one sweep.
All suggestions/comments are welcome.
Thanks
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

Forum statistics

Threads
1,214,908
Messages
6,122,187
Members
449,072
Latest member
DW Draft

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