|
Sub Test() では Application.Wait を使っているので
マクロ実行中はセルの操作ができないので
Application.OnTimeに変更しました。
Option Explicit
Dim myTime As Date
Dim myAddress As String
Sub 自動転記()
If myAddress = "" Then
myAddress = "B2"
ElseIf myAddress = "$G$5" Then
MsgBox "おわり"
myAddress = ""
Exit Sub
ElseIf Range(myAddress).Row = 5 Then
myAddress = Range(myAddress).Offset(-3, 1).Address
Else
myAddress = Range(myAddress).Offset(1).Address
End If
Range("A1").Copy Range(myAddress)
myTime = Now + TimeValue("00:00:01")
Application.OnTime TimeValue(myTime), "自動転記"
End Sub
Sub 自動転記停止()
On Error Resume Next
Application.OnTime TimeValue(myTime), "自動転記", , False
myAddress = ""
On Error GoTo 0
End Sub
|
|