Common Visual Basic for Application (VBA) Statements

AppActivateActivates an application window
BeepSounds a tone via the computer's speaker
CallTransfers control to another procedure
ChDirChanges the current directory
ChDriveChanges the current drive
CloseCloses a text file
ConstDeclares a constant value
DateSets the current system date
DeclareDeclares a reference to an external procedure in a Dynamic Link Library (DLL)
DeleteSettingDeletes a section or key setting from an application's entry in the Windows Registry
DimDeclares variables and (optionally) their data types
Do-LoopLoops through a set of instructions
EndUsed by itself, exits the program; also used to end a block of statements that begin with If, With, Sub, Function, Property, Type, or Select
EraseRe-initializes an array
ErrorSimulates a specific error condition
Exit DoExits a block of Do-Loop code
Exit ForExits a block of For-Next code
Exit FunctionExits a Function procedure
Exit PropertyExits a property procedure
Exit SubExits a subroutine procedure
FileCopyCopies a file
For Each-NextLoops through a set of instructions for each member of a series
For-NextLoops through a set of instructions a specific number of times
FunctionDeclares the name and arguments for a Function procedure
GetReads data from a text file
GoSub...ReturnBranches to and returns from a procedure
GoToBranches to a specified statement within a procedure
If-Then-ElseProcesses statements conditionally
Input #Reads data from a sequential text file
KillDeletes a file from a disk
LetAssigns the value of an expression to a variable or property
Line Input #Reads a line of data from a sequential text file
LoadLoads an object but doesn't show it
Lock...UnlockControls access to a text file
MidReplaces characters in a string with other characters
MkDirCreates a new directory
NameRenames a file or directory
On ErrorGives specific instructions for what to do in the case of an error
On...GoSubBranches, based on a condition
On...GoToBranches, based on a condition
OpenOpens a text file
Option BaseChanges the default lower limit for arrays
Option CompareDeclares the default comparison mode when comparing strings
Option ExplicitForces declaration of all variables in a module
Option PrivateIndicates that an entire module is Private
Print #Writes data to a sequential file
PrivateDeclares a local array or variable
Property GetDeclares the name and arguments of a Property Get procedure
Property LetDeclares the name and arguments of a Property Let procedure
Property SetDeclares the name and arguments of a Property Set procedure
PublicDeclares a public array or variable
PutWrites a variable to a text file
RaiseEventFires a user-defined event
RandomizeInitializes the random number generator
ReDimChanges the dimensions of an array
RemSpecifies a line of comments (same as an apostrophe ['])
ResetCloses all open text files
ResumeResumes execution when an error-handling routine finishes
RmDirRemoves an empty directory
SaveSettingSaves or creates an application entry in the Windows Registry
SeekSets the position for the next access in a text file
Select CaseProcesses statements conditionally
SendKeysSends keystrokes to the active window
SetAssigns an object reference to a variable or property
SetAttrChanges attribute information for a file
StaticDeclares variables at the procedure level so that the variables retain their values as long as the code is running
StopPauses the program
SubDeclares the name and arguments of a Sub procedure
TimeSets the system time
TypeDefines a custom data type
UnloadRemoves an object from memory
While...WendLoops through a set of instructions as long as a certain condition remains true
Width #Sets the output line width of a text file
WithSets a series of properties for an object
Write #Writes data to a sequential text file

Comments

Popular posts from this blog

50 Excel VBA Oral Interview Questions