[研究]VBA測試
2026-10-19
假設您已經有 Test.xlsx。
使用 Excel 開啟
Test.xlsx。按
Alt + F11,開啟 VBA 編輯器。- 選擇「插入」→「模組」。
- 輸入以下測試程式碼:
Sub HelloWorld()
Range("A1").Value = "Hello World"
Range("A2").Value = Now
End Sub回到 Excel,按
F12(另存新檔)。- 將檔案類型選為「Excel 啟用巨集的活頁簿(*.xlsm)」。
儲存後,按
Alt + F8,選擇HelloWorld,再按「執行」。
預期結果:
A1:顯示
Hello WorldA2:顯示目前日期與時間
(完)












沒有留言:
張貼留言