Sub addlog()
'
' addlog 巨集
' 自動貼即時
'
' 快速鍵: Ctrl+Shift+A
'
Rows("3:3").Select
Selection.Copy
Dim x As Long
x = Evaluate("=counta(A:A)")
'用Evaluate回傳=counta(A:A)的結果,並將值定義為變數x,在此處為3
y = x + 2
Rows(y & ":" & y).Select
'選擇第5行(3+2=5)
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub
研究半天,人生第一個自己寫成功的VBA。

沒有留言:
張貼留言