请参考: Option Explicit Sub SelectAllSameOval() Sheet1.Activate If LCase$(TypeName(Application.Selection)) <> "oval" Then MsgBox "请选中一个圆后再试!" Exit Sub End If Dim Shp As Shape, iW As Single, iH As Single, iNum As Integer iW = Selection.Width iH = Selection.Height iNum = 1 For Each Shp In Sheet1.Shapes With Shp If .AutoShapeType = msoShapeOval Then If .Width = iW And .Height = iH Then ''开始编号 .TextFrame.Characters.Text = CStr(iNum) & "#" iNum = iNum + 1 End If End If End With Next End Sub ' .
Option Explicit
Sub SelectAllSameOval()
Sheet1.Activate
If LCase$(TypeName(Application.Selection)) <> "oval" Then
MsgBox "请选中一个圆后再试!"
Exit Sub
End If
Dim Shp As Shape, iW As Single, iH As Single, iNum As Integer
iW = Selection.Width
iH = Selection.Height
iNum = 1
For Each Shp In Sheet1.Shapes
With Shp
If .AutoShapeType = msoShapeOval Then
If .Width = iW And .Height = iH Then
''开始编号
.TextFrame.Characters.Text = CStr(iNum) & "#"
iNum = iNum + 1
End If
End If
End With
Next
End Sub
'
.