Display Alert屬性

當刪除工作表時,隱藏警告訊息:
Sub DelSheet()
   Dim sheet As Worksheet
   Application.DisplayAlerts = False               '不顯示警告訊息
   For Each sheet As Worksheets
      If sheet.Name <> ActiveSheet.Name Then
         sheet.Delete
      End If
   Next
   Application.DisplayAlerts = True                '顯示警告訊息
End Sub

ScreenUpdating

不顯示執行過程,只顯示結果。
Application.ScreenUpdating = False          'Disable Screen Updating

Application.ScreenUpdating = True

Remarks:
最後要Enable Screen Updating

開啟/關閉Excel


Open Excel:
Sub Auto_open()
   MsgBox "Open"
End Sub

Close Excel:
Sub Auto_Close()
   MsgBox "Close"
End Sub

VBA:InputBox


Var = Application.InputBox (Prompt, Title, Default, Left, Top, HelpFile, HelpContextId, Type)

MsgBox函數


VAR = MsgBox (prompt, buttons, title)

Syntax





VBA基本語法














儲存格格式設定

將儲存格格式設定如下:(Custom the cell formatting as below)
"還有"0"天到期";"已過了"0"天";"今天到期";"已完成"

正數 (positive number) ; 零 (zero) ; 負數 (negative number) ; 文字 (text)

Sum of whole column

Sum up the whole column:

=SUM(INDIRECT("R2C:R[-1]C",FALSE))
R2  代表第二列,是絕對值,相等於A1表示法中的$2。
R[-1] 代表上一列,是相對值,會自動隨SUM()函數的位置而改變。
C    代表同一欄。

註:INDIRECT()的第二個引數FALSE,代表不用A1表示法,而使用R1C1表示法。

宣告資料型態