Skip to content

Instantly share code, notes, and snippets.

@guwidoe
Last active April 23, 2024 17:29
Show Gist options
  • Save guwidoe/c189073d62147edb22770db115cd0aca to your computer and use it in GitHub Desktop.
Save guwidoe/c189073d62147edb22770db115cd0aca to your computer and use it in GitHub Desktop.
Exhaustive list of VBA Keywords, including categories reserved and non-reserved

Exhaustive lists of VBA Keywords and Symbols

Copyright (c) 2023 Guido Witt-Dörring (MIT License)

This document attempts to provide various exhaustive lists of VBA keywords and symbols using various categorizations. This is useful because the official documentation is convoluted and incomplete and it is very difficult to derive such lists from official sources.

If you find missing keywords or mistakes in any of the lists or have any suggestions, please don't hesitate to leave a comment below.

Table of Contents

  1. Keywords
    1. All Keywords
      1. All Keywords, sorted alphabetically
    2. Reserved Keywords
      1. Uncategorized, sorted alphabetically
    3. Non-Reserved Keywords
      1. Uncategorized, sorted alphabetically
    4. Keywords by Task
      1. Compiler Directives (Docs)
      2. Used in Multiple Contexts (Docs)
      3. Arrays (Docs)
      4. Control Flow (Docs)
      5. Conversion (Docs)
      6. Data Types (Docs)
      7. Type Conversion Functions (Docs)
      8. Dates and Times (Docs)
      9. Directories and files (Docs)
      10. Errors (Docs)
      11. Financial (Docs)
      12. Input and Output (Docs)
      13. Math (Docs)
      14. Miscellaneous (Docs)
      15. Registry (Docs)
      16. String manipulation (Docs)
      17. Variables and Constants declaration (Docs)
      18. Explicitly String-Typed Functions (Docs)
      19. Pointer Manipulation (Docs)
      20. Operators (Docs)
    5. Keywords by Type
      1. Compiler Directives (Docs)
      2. Operators (Docs)
      3. Inbuilt Functions (Docs)
      4. Statements (Docs)
      5. Inbuilt Objects (Docs
      6. Data Types (Docs)
      7. Control Flow (Docs)
      8. Other
  2. Symbols
    1. All Special Symbols
      1. All Special Symbols sorted by Unicode Codepoint
    2. All Special Symbols by Category
      1. Operator-symbols
      2. Delimiters
      3. Type Declaration Characters (Docs)
      4. Other Symbols with Special Meaning
      5. Other Reserved Symbols without Special Meaning
  3. Keywords and Symbols
    1. All Operators (Docs)
    2. All Operators by Category
      1. Arithmetic Operators
      2. Comparison Operators (Docs)
      3. Concatenation Operators
      4. Logical Operators
      5. Other Operators
  4. License

Keywords

All Keywords

All Keywords, sorted alphabetically

This list aims to contain all VBA keywords. This means that, for example, the keyword Base should be in this list, even though only occurs in combination with Option: (Option Base [0, 1]).

#Const
#Else
#ElseIf
#If
Abs
Access
AddressOf
Alias
And
Any
AppActivate
Append
AppleScriptTask	'MacOS only
Array
As
Asc
Atn
Attribute
Base
Beep
Binary
Boolean
ByRef
Byte
ByVal
Call
CallByName
Case
CBool
CByte
CCur
CDate
CDbl
CDec
CDecl
ChDir
ChDrive
Choose
Chr
Chr$
ChrB
ChrB$
ChrW
ChrW$
CInt
Clear
CLng
CLngLng	'64-bit only
CLngPtr	'VBA 7 only
Close
Collection
Command	'Access only
Command$	'Access only
Compare
Const
Cos
CreateObject
CSng
CStr
CurDir
CurDir$
Currency
CVar
CVErr
Database
Date
Date$
DateAdd
DateDiff
DatePart
DateSerial
DateValue
Day
DDB
Debug
Decimal
Declare
DefBool
DefByte
DefCur
DefDate
DefDbl
DefDec
DefInt
DefLng
DefLngLng	'64-bit only
DefLngPtr	'VBA 7 only
DefObj
DefSng
DefStr
DefVar
DeleteSetting
Dim
Dir
Do
DoEvents
Double
Each
Else
ElseIf
Empty
End
Enum
Environ
Environ$
EOF
Eqv
Erase
Err
ErrObject
Error
Error$
Event
Exit
Exp
Explicit
False
FileAttr
FileCopy
FileDateTime
FileLen
Filter
Fix
For
Format
Format$
FormatCurrency
FormatDateTime
FormatNumber
FormatPercent
FreeFile
Friend
Function
FV
Get
GetAllSettings
GetAttr
GetObject
GetSetting
Global
GoSub
GoTo
GrantAccessToMultipleFiles	'MacOS only
Hex
Hex$
Hour
If
IIf
IMEStatus
Imp
Implements
Input
Input$
InputB
InputB$
InputBox
InStr
InStrRev
Int
Integer
IPmt
IRR
Is
IsArray
IsDate
IsEmpty
IsError
IsMissing
IsNull
IsNumeric
IsObject
Join
Kill
LBound
LCase
LCase$
Left
Left$
LeftB
LeftB$
Len
LenB
Let
Lib
Like
Line
Load
Loc
Local
Lock
LOF
Log
Long
LongLong	'64-bit only
LongPtr	'VBA 7 only
Loop
LSet
LTrim
LTrim$
MacID	'MacOS only
MacScript	'MacOS only
Me
Mid
Mid$
MidB
MidB$
Minute
MIRR
MkDir
Mod
Module
Month
MonthName
MsgBox
Name
New
Next
Not
Nothing
Now
NPer
NPV
Null
Object
ObjPtr
Oct
Oct$
On
Open
Option
Optional
Or
Output
ParamArray
Partition
Pmt
PPmt
Preserve
Print
Private
Property
PtrSafe	'VBA 7 only
Public
Put
PV
QBColor
Raise
RaiseEvent
Random
Randomize
Rate
Read
ReDim
Rem
Replace
Reset
Resume
Return
RGB
Right
Right$
RightB
RightB$
RmDir
Rnd
Round
Rset
RTrim
RTrim$
SaveSetting
Scale
Second
Seek
Select
SendKeys
Set
SetAttr
Sgn
Shared
Shell
Sin
Single
SLN
Space
Space$
Spc
Split
Sqr
Static
Step
Stop
Str
Str$
StrComp
StrConv
String
String$
StrPtr
StrReverse
Sub
Switch
SYD
Tab
Tan
Text
Then
Time
Timer
TimeSerial
TimeValue
To
Trim
Trim$
True
Type
TypeName
TypeOf
UBound
Ucase
UCase$
Unload
Unlock
Until
UserForm
Val
Variant
VarPtr
VarType
vb_creatable
vb_exposed
vb_globalnamespace
vb_name
vb_predeclaredid
VBA
Weekday
WeekdayName
Wend
While
Width
With
WithEvents
Write
Xor
Year

Reserved Keywords

All VBA Reserved Keywords uncategorized, sorted alphabetically

Of the 'All Keywords' list, the following are reserved keywords:

Abs
AddressOf
And
Any
Array
As
Attribute
Boolean
ByRef
Byte
ByVal
Call
Case
CBool
CByte
CCur
CDate
CDbl
CDec
CDecl
CInt
CLng
CLngLng	'64-bit only
CLngPtr	'VBA 7 only
Close
Const
CSng
CStr
Currency
CVar
CVErr
Date
Date$
Debug
Decimal
Declare
DefBool
DefByte
DefInt
DefLng
DefLngLng	'64-bit only
DefLngPtr	'VBA 7 only
DefCur
DefSng
DefDbl
DefDec
DefDate
DefStr
DefObj
DefVar
Dim
Do
DoEvents
Double
Each
Else
Empty
End
Enum
Eqv
Erase
Event
Exit
False
Fix
For
Friend
Function
Get
Global
GoSub
GoTo
If
Imp
Implements
Input
Input$
InputB
InputB$
Int
Integer
Is
LBound
Len
LenB
Let
Like
Local
Lock
Long
LongLong	'64-bit only
LongPtr	'VBA 7 only
Loop
LSet
Me
Mod
New
Next
Not
Nothing
Null
On
Open
Option
Optional
Or
ParamArray
Print
Private
Public
Put
RaiseEvent
ReDim
Preserve
Rem
Resume
Return
RSet
Scale
Seek
Select
Set
Sgn
Shared
Single
Spc
Static
Stop
String
String$
Sub
Tab
Then
To
True
Type
TypeOf
UBound
Unlock
Until
Variant
vb_creatable
vb_exposed
vb_globalnamespace
vb_name
vb_predeclaredid
Wend
While
With
WithEvents
Write
Xor

Non-Reserved Keywords

All VBA Non-Reserved Keywords uncategorized, sorted alphabetically

Of the 'All Keywords' list, the following are non-reserved keywords:

Access
Alias
AppActivate
Append
AppleScriptTask	'MacOS only
Asc
Atn
Base
Beep
Binary
CallByName
ChDir
ChDrive
Choose
Chr
Chr$
ChrB
ChrB$
ChrW
ChrW$
Clear
Collection
Command	'Access only
Command$	'Access only
Compare
Cos
CreateObject
CurDir
CurDir$
Database
DateAdd
DateDiff
DatePart
DateSerial
DateValue
Day
DDB
DeleteSetting
Dir
Environ
Environ$
EOF
Err
ErrObject
Error
Error$
Exp
Explicit
FileAttr
FileCopy
FileDateTime
FileLen
Filter
Format
Format$
FormatCurrency
FormatDateTime
FormatNumber
FormatPercent
FreeFile
FV
GetAllSettings
GetAttr
GetObject
GetSetting
GrantAccessToMultipleFiles	'MacOS only
Hex
Hex$
Hour
IIf
IMEStatus
InputBox
InStr
InStrRev
IPmt
IRR
IsArray
IsDate
IsEmpty
IsError
IsMissing
IsNull
IsNumeric
IsObject
Join
Kill
LCase
LCase$
Left
Left$
LeftB
LeftB$
Lib
Line
Load
Loc
LOF
Log
LTrim
LTrim$
MacID	'MacOS only
MacScript	'MacOS only
Mid
Mid$
MidB$
Minute
MIRR
MkDir
Module
Month
MonthName
MsgBox
Name
Now
NPer
NPV
Object
ObjPtr
Oct
Oct$
Output
Partition
Pmt
PPmt
Property
PtrSafe	'VBA 7 only
PV
QBColor
Raise
Random
Randomize
Rate
Read
Replace
Reset
RGB
Right
Right$
RightB
RightB$
RmDir
Rnd
Round
RTrim
RTrim$
SaveSetting
Second
SendKeys
SetAttr
Shell
Sin
SLN
Space
Space$
Split
Sqr
Step
Str
Str$
StrComp
StrConv
StrPtr
StrReverse
Switch
SYD
Tan
Time
Timer
TimeSerial
TimeValue
Trim
Trim$
TypeName
UCase
UCase$
Unload
UserForm
Val
VarPtr
VarType
VBA
Weekday
WeekdayName
Width
Year

Keywords by Task

Note that the same keyword can appear in multiple categories.

In combination, the lists for the following task-categories should contain every keyword at least once.

Compiler Directives

#Const
#If
Then
#ElseIf
#Else

Used in multiple contexts

As
Binary
ByRef
ByVal
Date
Else
Empty
Error
False
For
Friend
Get
Input
Is
Len
LenB
Let
Lock
Me
Mid
New
Next
Nothing
Null
On
Option
Optional
ParamArray
Print
Private
Property
PtrSafe	'VBA 7 only
Public
Read
Resume
Seek
Set
Static
Step
String
Then
Time
To
True
WithEvents

Arrays

IsArray
Array
Option Base
Dim
Private
Public
Static
LBound
UBound
Erase
ReDim
Preserve

Control Flow

GoSub
Return
GoTo
On Error
On
GoSub
On
GoTo
DoEvents
End
Exit
Stop
Do
Loop
While
Until
For
Next
For Each
Next
While
Wend
With
Choose
If
Then
ElseIf
Else
Select Case
Switch
Call
Function
Property Get
Property Let
Property Set
Sub

Conversion

Chr
Chr$
ChrB
ChrB$
ChrW
ChrW$
Format
Format$
LCase
LCase$
Ucase
UCase$
DateSerial
DateValue
Hex
Hex$
Oct
Oct$
Str
Str$
Day
Month
Weekday
Year
Hour
Minute
Second
Asc
Val
TimeSerial
TimeValue

Data Types

Boolean
Byte
Currency
Date
Decimal
Double
Integer
Long
LongLong	'64-bit only
LongPtr	'VBA 7 only
Object
Single
String
Variant

Type conversion functions

CBool
CByte
CCur
CDate
CDbl
CDec
CInt
CLng
CLngLng	'64-bit only
CLngPtr	'VBA 7 only
CSng
CStr
CVar

Dates and times

Date
Date$
Now
Time
DateAdd
DateDiff
DatePart
DateSerial
DateValue
TimeSerial
TimeValue
Timer

Directories and Files

ChDir
ChDrive
FileCopy
MkDir
RmDir
Name
CurDir
CurDir$
FileDateTime
GetAttr
FileLen
Dir
SetAttr
GrantAccessToMultipleFiles	'MacOS only
MacID	'MacOS only

Errors

Clear
Error
Error$
Raise
Err
CVErr
On Error
Resume
IsError
ErrObject

Financial

DDB
SLN
SYD
FV
Rate
IRR
MIRR
NPer
IPmt
Pmt
PPmt
NPV
PV

Input and output

Open
Close
Binary
Access
Reset
Format
Print
Print #
Spc
Tab
Width #
FileCopy
EOF
FileAttr
FileDateTime
FileLen
FreeFile
GetAttr
Loc
LOF
Seek
Dir
Kill
Lock
Unlock
Name
Get
Input
Input$
InputB
InputB$
Input #
Line Input #
FileLen
FileAttr
GetAttr
SetAttr
Seek
Print #
Put
Write #
Append
Output
Random
Read
Write
Read Write
Shared
Lock Read
Lock Write
Lock Read Write

Math

Atn
Cos
Sin
Tan
Exp
Log
Sqr
Randomize
Rnd
Abs
Sgn
Fix
Int

Miscellaneous

DoEvents
AppActivate
Shell
SendKeys
Beep
Environ
Command	'Access only
Command$	'Access only
CreateObject
GetObject
QBColor
RGB
Scale
VBA
Global
Attribute
CDecl
Local
vb_creatable
vb_exposed
vb_globalnamespace
vb_name
vb_predeclaredid

Registry

DeleteSetting
GetSetting
GetAllSettings
SaveSetting

String manipulation

StrComp
StrConv
Format
Format$
Lcase
LCase$
Ucase
UCase$
Space
Space$
String
String$
Len
LenB
LSet
Rset
InStr
InStrRev
Left
Left$
LeftB
LeftB$
LTrim
LTrim$
Mid
Mid$
MidB
MidB$
Right
Right$
RightB
RightB$
RTrim
RTrim$
Trim
Trim$
Option Compare Binary
Option Compare Text
Option Compare Database
Asc
Chr
Chr$
ChrB
ChrB$
ChrW
ChrW$

Variable and constant declarations

Let
Const
Dim
Private
Public
New
Static
Option Private Module
IsArray
IsDate
IsEmpty
IsError
IsMissing
IsNull
IsNumeric
IsObject
TypeName
VarType
Me
Option Explicit
DefBool
DefByte
DefInt
DefLng
DefLngLng	'64-bit only
DefLngPtr	'VBA 7 only
DefCur
DefSng
DefDbl
DefDec
DefDate
DefStr
DefObj
DefVar
Any
Alias
Lib

Explicitly String-Typed Functions

Chr$	
ChrB$
ChrW$
Format$
Hex$
Oct$
Str$
Command$	'Access only
CurDir$
Date$
Environ$
Error$
Input$
InputB$
LCase$
Left$
LeftB$
LTrim$
RTrim$
Trim$
Mid$
MidB$
Right$
RightB$
Space$
String$
UCase$

Pointer manipulation

ObjPtr
StrPtr
VarPtr

Mac Only

AppleScriptTask
GrantAccessToMultipleFiles
MacID
MacScript

Operators

AddressOf
And
Eqv
Imp
Is
Like
Mod
Not
Or
TypeOf
Xor

Keywords by Type

In combination, the lists for the following keyword-types should contain every keyword at least once.

Compiler Directives

#Const
#If
Then
#ElseIf
#Else

Operators

AddressOf
And
Eqv
Imp
Is
Like
Mod
Not
Or
Xor

Inbuilt Functions

Abs
AppleScriptTask	'MacOS only
Array
Asc
Atn
CallByName
CBool
CByte
CCur
CDate
CDbl
CDec
Choose
Chr
Chr$
ChrB
ChrB$
ChrW
ChrW$
CInt
CLng
CLngLng	'64-bit only
CLngPtr	'VBA 7 only
Command	'Access only
Command$	'Access only
Cos
CreateObject
CSng
CStr
CurDir
CurDir$
CVar
CVErr
Date
Date$
DateAdd
DateDiff
DatePart
DateSerial
DateValue
Day
DDB
Dir
DoEvents
Environ
Environ$
EOF
Error
Error$
Exp
FileAttr
FileDateTime
FileLen
Filter
Fix
Format
Format$
FormatCurrency
FormatDateTime
FormatNumber
FormatPercent
FreeFile
FV
GetAllSettings
GetAttr
GetObject
GetSetting
GrantAccessToMultipleFiles	'MacOS only
Hex
Hex$
Hour
IIf
IMEStatus
Input
Input$
InputB
InputB$
InputBox
InStr
InStrRev
Int
IPmt
IRR
IsArray
IsDate
IsEmpty
IsError
IsMissing
IsNull
IsNumeric
IsObject
Join
LBound
LCase
LCase$
Left
Left$
LeftB
LeftB$
Len
LenB
Loc
LOF
Log
LTrim
LTrim$
MacID	'MacOS only
MacScript	'MacOS only
Mid
Mid$
MidB$
Minute
MIRR
Month
MonthName
MsgBox
Now
NPer
NPV
ObjPtr
Oct
Oct$
Partition
Pmt
PPmt
PV
QBColor
Rate
Replace
RGB
Right
Right$
RightB
RightB$
Rnd
Round
RTrim
RTrim$
Second
Seek
Sgn
Shell
Sin
SLN
Space
Space$
Spc
Split
Sqr
Str
Str$
StrComp
StrConv
String
String$
StrPtr
StrReverse
Switch
SYD
Tab
Tan
Time
Timer
TimeSerial
TimeValue
Trim
Trim$
TypeName
UBound
UCase
UCase$
Val
VarPtr
VarType
Weekday
WeekdayName
Year

Statements

AppActivate
Beep
Call
ChDir
ChDrive
Close
Const
Date
Declare
DefBool
DefByte
DefInt
DefLng
DefLngLng	'64-bit only
DefLngPtr	'VBA 7 only
DefCur
DefSng
DefDbl
DefDec
DefDate
DefStr
DefObj
DefVar
DeleteSetting
Dim
Do
Loop
While
Until
End
Enum
Erase
Error
Event
Exit
FileCopy
For Each
Next
For
Next
Function
Get
GoSub
Return
GoTo
If
Then
Else
Implements
Input #
Kill
Let
Line Input #
Load
Lock
Unlock
LSet
Mid
Mid$
MidB
MidB$
MkDir
Name
On Error
On
GoSub
On
GoTo
Open
Access
Option Base
Option Compare Binary
Option Compare Text
Option Compare Database
Option Explicit
Option Private
Print #
Private
Property Get
Property Let
Property Set
Public
Put
RaiseEvent
Randomize
ReDim
Preserve
Rem
Reset
Resume
RmDir
RSet
SaveSetting
Seek
Select Case
SendKeys
Set
SetAttr
Static
Stop
Sub
Time
Type
Unload
While
Wend
Width #
With
Write #

Inbuilt Objects

Collection
Debug
Err
VBA
Global
ErrObject
UserForm

Data Types

Boolean
Byte
Currency
Date
Decimal
Double
Integer
Long
LongLong	'64-bit only
LongPtr	'VBA 7 only
Object
Single
String
Variant

Control Flow

GoSub
Return
GoTo
On Error
On
GoSub
On
GoTo
DoEvents
End
Exit
Stop
Do
Loop
While
Until
For
Next
For Each
Next
While
Wend
With
Choose
If
Then
Else
Select Case
Switch
Call
Function
Property Get
Property Let
Property Set
Sub

Other

Any
Alias
As
Binary
ByRef
ByVal
Else
Empty
False
For
Friend
Lib
Me
New
Next
Nothing
Null
On
Option
Optional
ParamArray
Print
Property
PtrSafe	'VBA 7 only
Step
Then
To
True
WithEvents
CLngLng	'64-bit only
CLngPtr	'VBA 7 only
Clear
Raise
Print
New
Option Private Module
Me
Scale
Append
Output
Random
Read
Write
Read Write
Shared
Lock Read
Lock Write
Lock Read Write
Attribute
CDecl
Local
vb_creatable
vb_exposed
vb_globalnamespace
vb_name
vb_predeclaredid

Symbols

All Special Symbols

All Special Symbols sorted by Unicode Codepoint

!
"
#
$
%
&
'
(
)
*
+
,
-
.
/
:
;
<
=
>
?
@
[
\
]
^
_
`
{
|
}
~

All Special Symbols by Category

Operator-symbols

*
^
+
&
=
-
/
\
<
>

Delimiters

(
)
[
]
{
}
,
.
;

Type Declaration Characters

%
&
@
!
#
$
^ '64-bit only

Other Symbols with Special Meaning

'
_
#
:

Other Reserved Symbols without Special Meaning

?
`
|
~

Keywords and Symbols

All Operators

*
^
+
&
=
-
/
\
<
<=
>
>=
<>
AddressOf
And
Eqv
Imp
Is
Like
Mod
Not
Or
TypeOf
Xor

All Operators by Category

Arithmetic Operators

*
^
/
\
Mod
+
-

Comparison Operators

=
<
<=
>
>=
<>
Is
Like

Concatenation Operators

&
+

Logical Operators

And
Eqv
Imp
Not
Or
Xor

Other Operators

AddressOf
TypeOf

License

This document is distributed under the MIT License:

MIT License

Copyright (c) 2023 Guido Witt-Dörring

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment