Show Menu
Cheatography

Excel VBA Cheat Sheet (DRAFT) by

Excell VBA common ops

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Data types

Type
Desc­rip­tion
Variant
Any data type
Boolean
True / False
Byte, Integer, Long
Integers (Signed )
Single, Double
Floating point
String
String
Object
Any object reference
Date
Date & Hour
Array(10, 20, 30)
Array of 3 integers
Set dict = New Dictionary
Dictio­nnary (must reference Microsoft Scripting Runtime)
 

Control structures

Cond­iti­onnal Loop (While & Until)
Do While|­Until condi­tion
...
Loop
For Loop
For counter = start To end [Step s]
...
Next counter
ForEach Loop
For Each element In colle­ction
...
Next element
If-T­hen­-Else
If condi­tion Then
...
Else:
...
End If
Oper­ators
= (equals), <> (differs), <, >, <=, >=, And, Or, Not
 

Main objects

Applic­ation
Excel app
ThisWo­rkbook
Xls file containing the current macro
Active­Wor­kbook
Xls file with focus
Worksheets
Collection of sheets in the Workbook
Active­Sheet
Sheet with focus
Selection
Anything selected (often a range of cells)