开发者

MS Excel 2003 VBA - Is there a way to define a group of shapes/object into a "group"

So I have this global mapping scheme, and each country on it are individual shapes. I learned how to manipulate colors/fill based on certain criteria. So the way I do this, or the way I know how is one shape/object at a time.

For example USA is "C_USA", Canada is "C开发者_JS百科_CAN", etc.

So is there a way I can define countries into groups?? ie. I would like to put USA, CAN and MEX into a NorthAmerican group so that I can just call a sub for the group instead of all three individually.

It really stinks when I am over in Europe! :)

Thanks!


You can group shapes together as follows:

Dim NA_Group As Shape
Set NA_Group = ActiveSheet.Shapes.Range(Array("C_CAN", "C_USA", "C_MEX")).Group

Note that once you have done this once, you can no longer access the individual shapes by name without first ungrouping them, or by addressing them within the NA_Group.

Once you have them grouped, you can treat the whole group like a single shape:

NA_Group.Fill.ForeColor.RGB = RGB(255, 255, 0)
NA_Group.Line.ForeColor.RGB = RGB(255, 0, 0)
'// etc.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜