谢谢大家的回复。有可能做到这一点!有点。我说“有点”是因为从技术上讲,“功能”不会影响它周围的细胞。然而,实际上,没有用户能分辨出其中的区别。
诀窍是使用 Win32 API 来启动计时器,一旦它关闭,您就可以对任何单元格执行您想要的操作并关闭计时器。
现在我不是 COM 线程如何工作的专家(尽管我知道 VBA 是单单元线程),但要小心你的 Timer 与你的 Excel 进程一起运行并使其崩溃。这真的不是我建议作为所有其他电子表格的解决方案。
只需使用以下内容制作一个模块:
Option Explicit
Declare Function SetTimer Lib "user32" (ByVal HWnd As Long, _
ByVal IDEvent As Long, ByVal mSec As Long, _
ByVal CallFunc As Long) As Long
Declare Function KillTimer Lib "user32" (ByVal HWnd As Long, _
ByVal timerId As Long) As Long
Private timerId As Long
Private wb As Workbook
Private rangeName As String
Private blnFinished As Boolean
Public Sub RunTimer()
timerId = SetTimer(0, 0, 10, AddressOf Woohoo)
End Sub
Public Sub Woohoo()
Dim i As Integer
' For i = 0 To ThisWorkbook.Names.Count - 1
' ThisWorkbook.Names(i).Delete
' Next
ThisWorkbook.Worksheets("Sheet1").Range("D8").Value = "Woohoo"
KillTimer 0, timerId
End Sub