최근데이터 맨위줄 복사

Option Explicit

Dim Runst, on_sw

Sub Run() ‘ 실행

Application.OnKey “{F12}”, “stop_key”

Call stop_key

End Sub

Public Sub Copy2cell()
DoEvents
‘With Sheets(“Sheet2”).Cells(Application.Rows.Count, 1).End(xlUp).Offset(1, 0)
‘.Value = Format(Now(), “hh:mm”)
‘ .Offset(0, 1).Value = Sheets(“Sheet1”).Range(“A2”).Value
‘ .Offset(0, 2).Value = Sheets(“Sheet1”).Range(“B2”).Value
‘ .Offset(0, 3).Value = Sheets(“Sheet1”).Range(“C2”).Value
‘ .Offset(0, 4).Value = Sheets(“Sheet1”).Range(“D2”).Value

Sheets(“Sheet1”).Select
Range(“B2:E2”).Select
Selection.Copy
Sheets(“Sheet2”).Select
Range(“B2”).Select
Range(“A2”).Value = Format(Now(), “hh:mm”)
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range(“A1:G1”).Select
Application.CutCopyMode = False
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Range(“F3”).Select

‘End With

If on_sw = True Then
Runst = Now + TimeValue(“00:01:00”) ‘copy 시간을 지정 합니다
On Error Resume Next
Application.OnTime Runst, “Copy2cell”
On Error GoTo 0
End If
End Sub

Sub copy_stop() ‘종료

Application.OnKey “{F12}”

End Sub

Public Sub stop_key() ‘중지

on_sw = Not on_sw
If on_sw = True Then

Call Copy2cell

MsgBox “중지는 F12 키를 누르세요!”, vbInformation, “중지 방법”

Else

On Error Resume Next

Application.OnTime Runst, “Copy2cell”, schedule:=False

On Error GoTo 0
MsgBox “실행을 중지합니다!”, vbInformation, “중 지”
End If
End Sub

Previous article주요가격
Next articleAAINJAA PODEROSA – AAINJALA 150 TAMBORES

LEAVE A REPLY

Please enter your comment!
Please enter your name here