I recently published the following article about using a worksheet UDF to modify a shape on the worksheet.
As a brief review, cells B2 and C2 use a data validation list to populate the desired shape and color. Cells G2 and G3 contain the ModifyShape and ModifyShapeColor UDFs.
I have added 2 new features to this powerful technique. The first feature is the ability to change the size of the shape. Entering a value in cells C7 and C8 on the ShapeTest worksheet will change the size of the shape. I have added data validation to those cells to restrict values to the 0.5-2.0 range.
The other feature is the ability to add text to the shape. By entering the text message in cell B13, the new text is added to the shape. The following figure show the layout for the worksheet.
Here is the code for the UDF with the added features.
Function ModifyShape(ShapeNumber, ShapeType, Optional Vis As Boolean = True)
.AutoShapeType = ShapeType
.Visible = Vis
.DrawingObject.Characters.Text = Worksheets(“ShapeTest”).Range(“b13”).Value
.Height = .Height * Worksheets(“ShapeTest”).Range(“c7”).Value
.Width = .Width * Worksheets(“ShapeTest”).Range(“c8”).Value
ModifyShape = “done”
There are a few more features that I plan to add at a future date. Enjoy!
You can download the file here.