Consider an Excel spreadsheet with many forms. To select two forms:
ActiveSheet.Shapes.Range(Array("Freeform 314", "Freeform 278")).Select
The goal is to remove all shapes, starting with "Freeform".
I found an example referencing MS VBScript Regular Expression 5.5 , but forms are not on specific cells. The number or a certain number of figures is almost not shown. So the ugly solution may be the brute force of the string names, on the other hand, I hope you can help me achieve an elegant solution.
The code below does not work, but you can better understand the problem.
Sub DeleteShapes()
Dim re As New RegExp
re.Pattern = "Freeform*"
Dim cell As Range
For Each cell In ActiveSheet.Shapes.Range(Array(re.Pattern)).Select
Selection.delete
Next cell
End Sub
source
share