PDA

View Full Version : [SOLVED] How do I avoid selecting Shapes?



paulked
08-30-2019, 11:38 AM
Trimming down from the macro recorder I ended up with this:



For x = 1 To 17
ActiveSheet.Shapes.Range(Array("Rounded Rectangle " & x + 16)).Select
Selection.Text = Sheet2.Cells(3, x + 1).Value
Selection.ShapeRange.TextFrame2.TextRange.Font.Size = 16
Selection.ShapeRange.TextFrame2.TextRange.Font.Bold = msoTrue
Next


I tried to avoid the selection, wrongly!, by doing this:



For x = 1 To 17
With ActiveSheet.Shapes.Range(Array("Rounded Rectangle " & x + 16))
.Text = Sheet2.Cells(3, x + 1).Value
.ShapeRange.TextFrame2.TextRange.Font.Size = 16
.ShapeRange.TextFrame2.TextRange.Font.Bold = msoTrue
End With
Next


Anyone willing to share the dark magic of Shapes with me please?

Thanks

Kenneth Hobs
08-30-2019, 11:55 AM
With ActiveSheet.Shapes("Rounded Rectangle " & x + 16).OLEFormat.Object

paulked
08-30-2019, 12:05 PM
Many thanks, I don't work with shapes very often. I'll try to remember that... but how you remembered it is quite exceptional!