这可以在形状工作表_Change
事件来实现。将此添加到Shapes
工作表vba
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
Dim shp As Shape
Dim nw As Variant
Dim old As Variant
' in case there is an error...
On Error GoTo CleanUp
Set rng = Intersect(Target, [Shape])
If Not rng Is Nothing Then
' Save new name
nw = Target
' Prevent events firing while we change sheet values
Application.EnableEvents = False
' Get previous name
Application.Undo
old = Target
' Restore new name
Target = nw
' Rename selected Shapes
For Each shp In Me.Shapes
If shp.Name Like old & "#*" Then
shp.Name = nw & Mid(shp.Name, Len(old) + 1)
End If
Next
End If
CleanUp:
' Re-enable events
Application.EnableEvents = True
End Sub
谢谢,这真是太棒了...将修改使用第二列而不是数字字母? – Links
只需更改'shp.Name像旧的&##“'shp.Name像旧的&”*“。然后任何以旧名称开头的形状名称将被更改 –
如果这解决了您的问题,您应该接受答案(请单击打勾) –