Microsoft Excel VBA Dictionary
(By Category)
Note: Syntax/Terms are separated into categories
Directions: Click on “+” in the right hand corner to expand each section
-
Byte: An unsigned 8-bit value.
Integer: A 16-bit signed value.
Long: A 32-bit signed value.
Single: A single-precision floating-point value.
Double: A double-precision floating-point value.
Currency: Used for financial calculations.
Decimal: A 96-bit signed number.
Date: Represents date and time.
String: A sequence of characters.
Boolean: Represents True or False.
Object: A reference to an object.
Variant: Can contain any type except fixed-length strings.
LongLong: A 64-bit signed integer (64-bit VBA only).
LongPtr: A platform-specific integer.
-
Dim: Declare a variable with a specific data type.
Static: Declare a static variable that retains its value.
Public: Accessible by any other procedure in the project.
Private: Accessible only within the specific module.
ReDim: Resize a dynamic array.
Const: Declare a constant value that cannot be changed.
-
If...Then: Conditional statement to execute code if a condition is true.
ElseIf: Specifies a new condition if the previous condition is false.
Else: Specifies code to run if no conditions are true.
End If: Ends an If statement.
Select Case: Alternative to multiple If...Then...Else statements.
Case: Defines a possible condition within a Select Case statement.
Case Else: Defines code to run if no Case condition is true.
End Select: Ends a Select Case statement.
Do...Loop: Repeats a block of code as long as a condition is true.
While...Wend: Similar to Do...Loop but with different syntax.
For...Next: Repeats a block of code a specific number of times.
For Each...Next: Repeats a block of code for each element in a collection.
Exit For/Exit Do: Exits a loop prematurely.
-
Function: Defines a function that returns a value.
Sub: Defines a subroutine that doesn’t return a value.
Call: Calls a Sub procedure.
Return: Ends a function and returns a value.
Exit Function/Exit Sub: Exits a function or subroutine prematurely.
Optional: Indicates an optional argument in a procedure.
ByVal/ByRef: Passes arguments By Value or By Reference.
-
Error: Used to simulate the occurrence of an error.
On Error: Specifies what to do if an error occurs.
Resume: Specifies where to continue after an error.
Resume Next: Continues on the line immediately following the one where the error occurred.
Err Object: Contains information about the error.
-
Set: Assigns an object reference.
CreateObject: Creates an object of a specified type.
GetObject: Retrieves an existing object.
With...End With: Groups code for a specific object.
Collection: A group of objects.
Add: Adds an item to a collection.
Remove: Removes an item from a collection.
Count: Returns the number of items in a collection.
Item: Returns a specific item in a collection.
-
Open: Opens a file.
Close: Closes a file.
Input: Reads data from a file.
Print: Outputs data to a file.
Write: Writes data to a file.
Get: Reads data from a random-access file.
Put: Writes data to a random-access file.
Line Input: Reads a line from a sequential file.
FileLen: Returns the length of a file.
Dir: Returns the name of a file or directory.
-
Array: Defines an array.
LBound: Returns the smallest subscript for the indicated dimension of an array.
UBound: Returns the largest subscript for the indicated dimension of an array.
IsArray: Checks if a variable is an array.
Erase: Removes elements from an array.
-
Date: Returns or sets the current date.
Time: Returns or sets the current time.
Now: Returns the current date and time.
DateAdd: Adds a time interval to a date.
DateDiff: Returns the difference between two dates.
DatePart: Returns part of a given date.
DateSerial: Returns a date based on year, month, and day.
-
Len: Returns the length of a string.
Left: Returns the left part of a string.
Right: Returns the right part of a string.
Mid: Returns a specified number of characters from a string.
Trim: Removes leading and trailing spaces.
LTrim/RTrim: Removes leading or trailing spaces.
InStr: Returns the position of a substring.
Replace: Replaces occurrences of a substring.
StrComp: Compares two strings.
UCase/LCase: Converts a string to upper or lower case.
-
CBool: Converts to Boolean.
CByte: Converts to Byte.
CCur: Converts to Currency.
CDate: Converts to Date.
CDbl: Converts to Double.
CInt: Converts to Integer.
CLng: Converts to Long.
CSng: Converts to Single.
CStr: Converts to String.
CVar: Converts to Variant.
-
MsgBox: Displays a dialog box with a message.
InputBox: Displays a dialog box for user input.
Type: Defines a custom data type.
Enum: Defines a set of named constant values.
Like: Compares a string against a pattern.
Is: Compares object references.
-
Abs: Returns the absolute value.
Atn: Returns the arctangent.
Cos: Returns the cosine.
Exp: Returns the exponential value.
Int: Returns the integer part of a number.
Fix: Returns the integer part, keeping the sign.
Log: Returns the natural logarithm.
Rnd: Returns a random number.
Sin: Returns the sine.
Sqr: Returns the square root.
Tan: Returns the tangent.
-
ActiveSheet: Refers to the current worksheet.
ActiveWorkbook: Refers to the current workbook.
Range: Refers to a specific range of cells.
Cells: Refers to a specific cell.
Worksheets: Refers to a collection of worksheets.
Charts: Refers to a collection of charts.
PivotTables: Refers to a collection of PivotTables.
Names: Refers to named ranges.
Formula: Sets or returns the formula for a cell.
-
CreateObject: Creates an instance of an automation object.
GetObject: Gets a reference to an existing object.
Shell: Runs an executable program.
SendKeys: Sends keystrokes to an application.
-
Debug.Print: Outputs text to the Immediate window.
Stop: Stops code execution.
Err: Contains information about runtime errors.
On Error: Specifies error handling.
IsError: Checks if an expression is an error value.
-
Application: Refers to the parent application (e.g., Excel).
AddIns: Refers to a collection of add-ins.
Workbooks: Refers to a collection of open workbooks.
Properties: Refers to an object's properties.
Methods: Refers to an object's methods.
Events: Refers to an object's events.
-
UserForm: Defines a custom dialog box.
TextBox: Allows users to enter text.
Label: Displays descriptive text.
ComboBox: A dropdown list of items.
ListBox: A list of selectable items.
CheckBox: Allows users to select true/false or yes/no.
OptionButton: A set of options where only one can be selected.
Frame: A container for grouping controls.
CommandButton: A clickable button to perform an action.
-
Click: Occurs when a control is clicked.
DoubleClick: Occurs when a control is double-clicked.
KeyPress: Occurs when a key is pressed.
MouseMove: Occurs when the mouse pointer is moved over a control.
Change: Occurs when the value of a control changes.
-
MkDir: Creates a new directory.
RmDir: Removes a directory.
ChDir: Changes the current directory.
Kill: Deletes files.
FileCopy: Copies a file.
Name: Renames a file or directory.
FileDateTime: Returns the date and time a file was created or last modified.
FileExists: Checks if a file or directory exists.
-
Connection: Represents a connection to a data source.
Recordset: Represents a set of records from a database.
Command: Represents a command to execute against a data source.
Fields: Represents a collection of fields in a Recordset.
Open: Opens a connection or Recordset.
Close: Closes a connection or Recordset.
Execute: Executes a command.
-
XMLHTTP: Sends HTTP requests and receives responses.
DOMDocument: Represents an XML document.
Load: Loads an XML document.
SelectNodes: Selects nodes in an XML document.
CreateElement: Creates an element in an XML document.
-
Attributes: Defines additional characteristics for programming elements.
Implements: Declares that a class implements an interface.
Delegates: Allows passing a reference to a procedure.