我写了一个简单的宏来复制和粘贴一行相邻的两列,然后我添加了 app.ontime 来自动运行复制和粘贴宏。我有多行数据要应用我的宏。有什么想法吗?
Public Sub PasteDynamicData()
'runs TestKDdata every Xmin
Sheets("MOVINGAVGDATAFromKD").Range("C4").Copy
Range("J4").PasteSpecial Paste:=xlPasteValuesAndNumberFormats, operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Sheets("MOVINGAVGDATAFromKD").Range("I4:j4").Insert _
shift:=xlDown
Sheets("MOVINGAVGDATAFromKD").Range("D4").Copy
Range("m4").PasteSpecial Paste:=xlPasteValuesAndNumberFormats, operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Sheets("MOVINGAVGDATAFromKD").Range("L4:M4").Insert _
shift:=xlDown
Sheets("MOVINGAVGDATAFromKD").Range("i87:m87").ClearContents
End Sub
Public Sub UpdateDataClock()
'Clock that prompts running of PasteDynamicData
Sheets("MOVINGAVGDATAFromKD").Select
Call PasteDynamicData
Nexttick = Now + TimeValue("00:00:30")
Application.OnTime Nexttick, "updatedataclock"
If Time >= TimeValue("16:00:00") Then
Application.OnTime Nexttick, "updatedataclock", , False
End If
End Sub
(I declared "nexttick as date" in the module).