有时,当我单击我创建的 Excel 电子表格中的按钮时,当我释放按钮时,工作表会快速放大和缩小。VBA 代码中没有任何内容指示它执行此操作,而且这种情况并非每次都会发生。
代码如下:
Sub CopyCellR1()
Dim Sh As Shape
With ActiveSheet
For Each Sh In .Shapes
If Not Intersect(Sh.TopLeftCell, .Range("A1:C1")) Is Nothing Then
Sh.Select
With Selection.Font
.ColorIndex = 1
End With
End If
Next Sh
End With
Dim c As Object
Set c = ActiveSheet.Buttons(Application.Caller)
c.Select
With Selection.Font
.ColorIndex = 5
End With
Dim r As Range
Set r = ActiveSheet.Buttons(Application.Caller).TopLeftCell
Range(Cells(r.Row, r.Column), Cells(r.Row, r.Column)).Select
Selection.Copy
Range("E1").Select
ActiveCell.PasteSpecial
End Sub
任何帮助都将非常有帮助。谢谢!
答案1
我搞明白了。似乎是因为工作表缩小太多(仅缩小到 80%)而出现了某种问题。当我放大到 100% 时,问题就消失了。