我已在Excel - Autoshape get it's name from cell (value)上提交了问题,但我的每个回复都被删除了,所以我会打开新的....请不要立即删除
这是文件并且工作正常但我现在只能使用方形
在home1,home2,office1,office2,stair1,stair2 ..以指示如果用户在列表中更改为建筑物的位置,则仅更改具有该名称而不是其他人的方块......?或办公室到电梯只有办公室形状更新
这个带有形状的列A可以删除,只留下B名和C号,因为我只使用正方形
抱歉,对VBA不太了解检查图片
答案 0 :(得分:0)
这可以通过形状工作表上的_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