VBA Cheat Sheet
VBA Cheat Sheet
ThisWorkbook
Path strPath = ThisWorkbook.Path
strFile = Dir(“C:\test” & “\*”)
Do While Len(strFile) > 0
Debug.Print strFile
strFile = Dir
Loop Through All Files in Folder Loop
Application.ScreenUpdating = False
Screen Updating Application.ScreenUpdating = True
Application.DisplayAlerts = False
Display Alerts Application.DisplayAlerts = True
Application.EnableEvents = False
Events Application.EnableEvents = True
Application.EnableCancelKey =
xlDisabled
Application.EnableCancelKey =
Enable Cancel Key xlInterrupt
Text Compare –
Ignore Case Option Compare Text
Require Variable Declaration Option Explicit
Application.Calculation = xlManual
Automatic Calcu-lations Application.Calculation = xlAutomatic
Application.ErrorCheckingOptions.
BackgroundChecking = False
Application.ErrorCheckingOptions.
Background Error Checking BackgroundChecking = True
Application.DisplayFormulaBar = False
Display Formula Bar Application.DisplayFormulaBar = True
ActiveWindow.FreezePanes = False
Freeze Panes ActiveWindow.FreezePanes = True
Application.DisplayFullScreen = False
Full Screen View Application.DisplayFullScreen = True
ActiveWindow.View =
xlPageBreakPreview
PageBreak Preview ActiveWindow.View = xlNormalView
With ActiveWindow
.DisplayHorizontalScrollBar = False
.DisplayVerticalScrollBar = False
End WithWith ActiveWindow
.DisplayHorizontalScrollBar = True
.DisplayVerticalScrollBar = True
Display Scroll Bars End With
Application.DisplayStatusBar = False
Display Status Bar Application.DisplayStatusBar = True
Application.StatusBar = “I’m working
Now!!!”
Status Bar Contents Application.StatusBar = False
ActiveWindow.DisplayWorkbookTabs
= False
ActiveWindow.DisplayWorkbookTabs
Display Work-book Tabs = True
Application.UserName = “AutomateExcel.
UserName com”
Application.Caption = “AutomateExcel
App Caption Model”
Zoom ActiveWindow.Zoom = 80
If dict.Exists(“Key”) Then
MsgBox “Exists”
Check For Value End If
Remove Item dict.Remove (“Key”)
Remove All Items dict.RemoveAll
Dim key As Variant
For Each key In dict.Keys
MsgBox key, dict(key)
Loop Through Items Next key
Count Items dict.Count
Make Key Case Sensitive dict.CompareMode = vbBinaryCompare
Make Key Case Insensitive dict.CompareMode = vbTextCompare