我正在使用一个宏来复制活动工作表,并将其重命名为任何单元格“C2”的值。唯一的问题是,当它复制工作表时,它以某种方式从我的工作表的顶部移除了表单按钮,并将它们替换为单元格'AF‘中的代码=$c$2。
据我所知,从VBA代码中看不到引用单元格'AF‘的内容。有人能告诉我为什么会这样吗?
Sub Copy_Rename()
Dim shtName As String
shtName = ActiveSheet.Name
ActiveSheet.Copy before:=ActiveSheet
ActiveSheet.Name = Range("C2").Value
Sheets(shtName).Activate
End Sub发布于 2019-10-31 05:31:22
试试这个:
Sub Copy_Rename()
Dim sht As Worksheet
Set sht = ActiveSheet
Application.CopyObjectsWithCells = True '<< to also copy objects not just cell contents etc
sht.Copy before:=sht
'Get the just-created sheet
With Sheets(sht.Index - 1)
.Name = sht.Range("C2").Value
.Activate
End With
End Subhttps://stackoverflow.com/questions/58633843
复制相似问题