excel macro definitions
TRANSCRIPT
-
8/19/2019 Excel Macro Definitions
1/23
VBE GlossaryOther Versions
Contribute to this content
Use GitHub to suggest and submit changes. See our guidelines for contributidocumentation.
access keyA key pressed while holding down the ALT key that allows the user to open a menu, carry out a
command, select an obect, or mo!e to an obect" #or e$ample, ALT%# opens the File menu"
Acti!e& controlAn obect that you place on a form to enable or enhance a user's interaction with an application"
Acti!e& (ontrols ha!e e!ents and can be incorporated into other controls" These controls ha!e an "oc$
)le name e$tension"
Acti!e& obectAn obect that is e$posed to other applications or programming tools through Automation interfaces"
add*inA customi+ed tool that adds capabilities to the Visual Basic de!elopment en!ironment"
A-. (haracter -etAmerican ational -tandards .nstitute /A-.0 1*bit character set used to represent up to 234
characters /562330 using your keyboard" The )rst 721 characters /567280 correspond to the letters and
symbols on a standard 9"-" keyboard" The second 721 characters /72162330 represent special
characters, such as letters in international alphabets, accents, currency symbols, and fractions"applicationA collection of code and !isual elements that work together as a single program" :e!elopers can build
and run applications within the de!elopment en!ironment, while users usually run applications as
e$ecutable )les outside the de!elopment en!ironment"
argumentA constant, !ariable, or e$pression passed to a procedure"
arrayA set of se;uentially inde$ed elements ha!ing the same intrinsic data type" Each element of an array
has a uni;ue identifying inde$ number" (hanges made to one element of an array don't a
-
8/19/2019 Excel Macro Definitions
2/23
An image represented by pi$els and stored as a collection of bits in which each bit corresponds to one
pi$el" On color systems, more than one bit corresponds to each pi$el" A bitmap usually has a "bmp )le
name e$tension"
bitwise comparisonA bit*by*bit comparison between identically positioned bits in two numeric e$pressions"
Boolean e$pressionAn e$pression that e!aluates to either True or False"
Boolean data typeA data type with only two possible !alues, True /*70 or False /50" Boolean !ariables are stored as 74*
bit /2*byte0 numbers"
bound controlA data*aware control that can pro!ide access to a speci)c )eld or )elds in a database through
a Data control" A data*aware control is typically bound to a Data control through
its DataSource and DataField properties" =hen a Data control mo!es from one record to the ne$t,
all bound controls connected to the Data control change to display data from )elds in the current
record" =hen users change data in a bound control and then mo!e to a di
-
8/19/2019 Excel Macro Definitions
3/23
A module containing public code that can be shared among all modules in a proect" A code module is
referred to as a standard module in later !ersions of Visual Basic"
code paneA pane contained in a code window that is used for entering and editing code" A code window can
contain one or more code panes"
collectionAn obect that contains a set of related obects" An obect's position in the collection can change
whene!er a change occurs in the collectionC therefore, the position of any speci)c obect in the
collection can !ary"
command line The path, )le name, and argument information pro!ided by the user to run a program"
comment Te$t added to code that e$plains how the code works" .n Visual Basic, a comment line can start with
either an apostrophe /'0 or with the Remkeyword followed by a space"
comparison operatorA character or symbol indicating a relationship between two or more !alues or e$pressions" These
operators include less than /=0, not e;ual /0, and e;ual /=0" Additional comparison operators include Is and ike" ote
that Is and ike can't be used as comparison operators in a Select Case statement"
compiler directi!eA command used to alter the action of the compiler"
compile time The period during which source code is translated to e$ecutable code"
conditional compiler constantA Visual Basic identi)er that is de)ned using the !Const compiler directi!e or de)ned in the host
application and used by other compiler directi!es to determine when or if certain blocks of Visual Basic
code are compiled"
constantA named item that retains a constant !alue throughout the e$ecution of a program" A constant can be
a string or numeric literal, another constant, or any combination that includes arithmetic or logical
operators e$cept Is and e$ponentiation" Each host application can de)ne its own set of constants"
Additional constants can be de)ned by the user with the Const statement" >ou can use constants
anywhere in your code in place of actual !alues"
containerAn obect that can contain other obects"
controlAn obect you can place on a form that has its own set of recogni+ed properties, methods, and e!ents"
>ou use controls to recei!e user input, display output, and trigger e!ent procedures" >ou can
manipulate most controls using methods" -ome controls are interacti!e /responsi!e to user actions0,
while others are static /accessible only through code0"
control arrayA group of controls that share a common name, type, and e!ent procedures" Each control in an array
has a uni;ue inde$ number that can be used to determine which control recogni+es an e!ent"
(urrency data typeA data type with a range of *D22,8,25,413,F88"3151 to D22,8,25,413,F88"3158" 9se this data
type for calculations in!ol!ing money and for )$ed*point calculations where accuracy is particularly
important" The at sign /"0 type*declaration character represents Currenc# in Visual Basic"
data type
http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/
-
8/19/2019 Excel Macro Definitions
4/23
The characteristic of a !ariable that determines what kind of data it can hold" :ata types
include B#te, Boolean, Integer, ong, Currenc#, Decimal,Single, Dou$le, Date, String, %$&ect,
ariant /default0, and user*de)ned types, as well as speci)c types of obects"
:ate data typeA data type used to store dates and times as a real number" :ate !ariables are stored as 4F*bit /1*
byte0 numbers" The !alue to the left of the decimal represents a date, and the !alue to the right of the
decimal represents a time"
date e$pressionAny e$pression that can be interpreted as a date, including date literals, numbers that look like dates,
strings that look like dates, and dates returned from functions" A date e$pression is limited to numbers
or strings, in any combination, that can represent a date from anuary 7, 755 6 :ecember 7, DDDD"
:ates are stored as part of a real number" Values to the left of the decimal represent the dateC !alues
to the right of the decimal represent the time" egati!e numbers represent dates prior to :ecember
5, 71DD"
date literalAny se;uence of characters with a !alid format that is surrounded by number signs / !0" Valid formats
include the date format speci)ed by the locale settings for your code or the uni!ersal date format"
#or e$ample, H72I7ID2H is the date literal that represents :ecember 7, 7DD2, where English*9"-" is
the locale setting for your application" 9se date literals to ma$imi+e portability across nationallanguages"
date separators(haracters used to separate the day, month, and year when date !alues are formatted" The characters
are determined by system settings or by theFormat function"
:B(-A character set that uses 7 or 2 bytes to represent a character, allowing more than 234 characters to
be represented"
dynamic data e$change /::E0An established protocol for e$changing data through acti!e links between applications that run under
Jicrosoft =indows"
:ecimal data typeA data type that contains decimal numbers scaled by a power of 75" #or +ero*scaled numbers, that is,
numbers with no decimal places, the range is %I*8D,221,742,37F,24F,8,3D,3F,D35,3" #or
numbers with 21 decimal places the range is %I*8"D22174237F24F83D3FD353" The smallest
non*+ero number that can be represented as a Decimal is 5"5555555555555555555555555557"
ote that at this time the Decimal data type can only be used within a ariant" >ou cannot declare a
!ariable to be of type Decimal" >ou can, howe!er, create a ariant whose subtype is Decimal using
the CDec function"
declarationone$ecutable code that names a constant, !ariable, or procedure, and speci)es its characteristics,
such as data type" #or :LL procedures, declarations specify names, libraries, and arguments"
designer@ro!ides a !isual design window in the Visual Basic de!elopment en!ironment" >ou can use this
window to design new classes !isually" Visual Basic has built*in designers for forms" The @rofessional
and Enterprise editions of Visual Basic include designers for Acti!e& controls and Acti!e& documents"
design time The time during which you build an application in the de!elopment en!ironment by adding controls,
setting control or form properties, and so on" .n contrast, during run time, you interact with the
application like a user"
de!elopment en!ironment
http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/
-
8/19/2019 Excel Macro Definitions
5/23
The part of the application where you write code, create controls, set control and form properties, and
so on" This contrasts with running the application"
dynamic*link library /:LL0A library of routines loaded and linked into applications at run time" :LLs are created with other
programming languages such as (, JA-J, or #OTA"
docked windowA window that is attached to the frame of the main window"
documentAny self*contained work created with an application and gi!en a uni;ue )le name"
:ouble data typeA data type that holds double*precision Koating*point numbers as 4F*bit numbers in the range
*7"8D84D7F1427E51 to *F"DF5434F31F72F8E*2F for negati!e !aluesC F"DF5434F31F72F8E*2F
to 7"8D84D7F1422E51 for positi!e !alues" The number sign /!0 type*declaration character
represents the Dou$le in Visual Basic"
Empty.ndicates that no beginning !alue has been assigned to a ariant !ariable" An (mpt# !ariable is
represented as 5 in a numeric conte$t or a +ero*length string /0 in a string conte$t"
error numberA whole number in the range 5 6 43,33 that corresponds to the )um$er property setting of
the (rr obect" =hen combined with the Descriptionproperty setting of the (rr obect, this number
represents a particular error message"
e!ent source obectAn obect that is the source of e!ents that occur in response to an action" An e!ent source obect is
returned by a property" #or e$ample, theCommandBar(*ents property returns
the CommandBar(*ents obect"
e$ecutable )leA =indows*based application that can run outside the de!elopment en!ironment" An e$ecutable )le
has an "e$e )le name e$tension"
e$pressionA combination of keywords, operators, !ariables, and constants that yields a string, number, or obect"
An e$pression can be used to perform a calculation, manipulate characters, or test data"
)le numberumber used in the %pen statement to open a )le" 9se )le numbers in the range 76233, inclusi!e, for
)les not accessible to other applications" 9se )le numbers in the range 2346377 for )les accessible
from other applications"
focus The ability to recei!e mouse clicks or keyboard input at any one time" .n the Jicrosoft =indows
en!ironment, only one window, form, or control can ha!e this ability at a time" The obect that has the
focus is normally indicated by a highlighted caption or title bar" The focus can be set by the user or by
the application"
formA window or dialog bo$" #orms are containers for controls" A multiple*document interface /J:.0 form
can also act as a container for child forms and some controls"
form moduleA )le in a Visual Basic proect with an "frm )le name e$tension that can contain graphical descriptions
of a formC its controls and their property settingsC form*le!el declarations of constants, !ariables, and
e$ternal proceduresC and e!ent and general procedures"
#unction procedureA procedure that performs a speci)c task within a program and returns a !alue" A Function procedure
begins with a Function statement and ends with an (nd Function statement"
http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/
-
8/19/2019 Excel Macro Definitions
6/23
general procedureA procedure that must be e$plicitly called by another procedure" .n contrast, an e!ent procedure is
in!oked automatically in response to a user or system action"
graphics methodA method that operates on an obect such as a Form, +ictureBo,, or +rinter, and performs run*time
drawing operations such as animation or simulation" The graphics methods
are Circle, Cls, ine, +aint+icture, +oint, +rint, and +Set"
host applicationAny application that supports the use of Visual Basic for Applications, for e$ample, Jicrosoft E$cel,
Jicrosoft @roect, and so on"
iconA graphical representation of an obect or conceptC commonly used to represent minimi+ed
applications in Jicrosoft =indows" An icon is a bitmap with a ma$imum si+e of 2 $ 2 pi$els" .cons
ha!e an "ico )le name e$tension"
identi)erAn element of an e$pression that refers to a constant or !ariable"
in processunning in the same address space as an application"
insertable obectAn application obect that is a type of custom control, such as a Jicrosoft E$cel worksheet"
.nteger data typeA data type that holds integer !ariables stored as 2*byte whole numbers in the range *2,841 to
2,848" The Integer data type is also used to represent enumerated !alues" The percent sign / -0
type*declaration character represents an Integer in Visual Basic"
intrinsic constantsA constant pro!ided by an application" Visual Basic constants are listed in the obect library and can be
!iewed with the %$&ect Bro.ser" Because you can't disable intrinsic constants, you can't create a
user*de)ned constant with the same name"
keywordA word or symbol recogni+ed as part of the Visual Basic programming languageC for e$ample, a
statement, function name, or operator"
line*continuation character The combination of a space followed by an underscore / /0 used in the de!elopment en!ironment to
e$tend a single logical line of code to two or more physical lines" Mowe!er, you can't use a line*
continuation character to continue a line of code within a string e$pression"
line label9sed to identify a single line of code" A line label can be any combination of characters that starts with
a letter and ends with a colon /00" Line labels are not case sensiti!e and must begin in the )rst column"
line number9sed to identify a single line of code" A line number can be any combination of digits that is uni;ue
within the module where it is used" Line numbers must begin in the )rst column"
linked windowA window that is oined to another window other than the main window"
linked window frameA window frame containing multiple windows that ha!e been linked together"
locale The set of information that corresponds to a gi!en language and countryIregion" The code locale
setting a
-
8/19/2019 Excel Macro Definitions
7/23
The system locale setting a
-
8/19/2019 Excel Macro Definitions
8/23
ote that the named arguments don't ha!e to appear in the normal positional order in the synta$"
ullA !alue indicating that a !ariable contains no !alid data" )ull is the result of an e$plicit assignment
of )ull to a !ariable or any operation between e$pressions that contain )ull"
numeric data typeAny intrinsic numeric data type /B#te, Boolean, Integer, ong, Currenc#, Single, Dou$le,
or Date0"
numeric e$pressionAny e$pression that can be e!aluated as a number" Elements of an e$pression can include any
combination of keywords, !ariables, constants, and operators that result in a number"
numeric typeAny intrinsic numeric data type /B#te, Boolean, Integer, ong, Currenc#, Single, Dou$le, or Date0
or any ariant numeric subtype
/(mpt#,Integer, ong, Single, Dou$le, Currenc#, Decimal, Date, (rror, Boolean, or B#te0"
obectA combination of code and data that can be treated as a unit, for e$ample, a control, form, or
application component" Each obect is de)ned by a class"
Obect bo$A list bo$ at the upper*left corner of the Code window that lists the form and controls in the form to
which the code is attached, or a list bo$ located at the top of the +roperties window that lists the
form and its controls"
Obect BrowserA dialog bo$ in which you can e$amine the contents of an obect library to get information about the
obects pro!ided"
Obect data typeA data type that represents any %$&ect reference" %$&ect !ariables are stored as 2*bit /F*byte0
addresses that refer to obects"
obect e$pressionAn e$pression that speci)es a particular obect and can include any of the obect's containers" #or
e$ample, an application can ha!e an 3pplicationobect that contains a Document obect that
contains a Te,t obect"
obect libraryA )le with the "olb e$tension that pro!ides information to Automation controllers /like Visual Basic0
about a!ailable obects" >ou can use the %$&ect Bro.ser to e$amine the contents of an obect library
to get information about the obects pro!ided"
obect moduleA module that contains code speci)c to an obect, for e$ample, class module, form module, and
document module" Obect modules contain the code behind their associated obects" The rules for
obect modules di
-
8/19/2019 Excel Macro Definitions
9/23
pathA string e$pression specifying a directory or folder location" The location can include a dri!e
speci)cation"
piA mathematical constant e;ual to appro$imately "7F73D24331D8D2"
pointA point is 7I82 inch" #ont si+es are usually measured in points"
print +one@rint +ones begin e!ery 7F columns" The width of each column is an a!erage of the width of all
characters in the point si+e for the selected font"
@ri!ateVariables that are !isible only to the module in which they are declared"
procedureA named se;uence of statements e$ecuted as a unit" #or e$ample, Function, +ropert#, and Su$ are
types of procedures" A procedure name is always de)ned at module le!el" All e$ecutable code must be
contained in a procedure" @rocedures can't be nested within other procedures"
@rocedure bo$A list bo$ at the upper*right corner of the Code window and the De$ug window that displays the
procedures recogni+ed for the obect displayed in the %$&ect bo$"
procedure callA statement in code that tells Visual Basic to e$ecute a procedure"
procedure le!el:escribes statements located within a Function, +ropert#, or Su$ procedure" :eclarations are
usually listed )rst, followed by assignments and other e$ecutable code"
ote that module*le!el code resides outside a procedure block"
proectA set of modules"
@roect windowA window that displays a list of the form, class, and standard modulesC the resource )leC and
references in your proect" #iles with "oc$ and "!b$ )le name e$tensions aren't displayed in
the +ro&ect window"
@roperties windowA window used to display or change properties of a selected form or control at design time" -ome
custom controls ha!e customi+ed +ropertieswindows"
propertyA named attribute of an obect" @roperties de)ne obect characteristics such as si+e, color, and screen
location, or the state of an obect, such as enabled or disabled"
@roperty procedureA procedure that creates and manipulates properties for a class module" A +ropert# procedure begins
with a +ropert# et, +ropert# 4et, or+ropert# Set statement and ends with an (nd
+ropert# statement"
@ublicVariables declared using the +u$lic statement are !isible to all procedures in all modules in allapplications unless %ption +ri*ate 2odule is in e
-
8/19/2019 Excel Macro Definitions
10/23
its proect name" Any combination of direct and indirect references between proects is !alid as long as
they do not result in a complete cycle"
referencing proect The current proect" Mow you create a link to a proect depends on the host application" #or e$ample, to
directly reference a proect in Jicrosoft E$cel, select the proect from the Re5erences dialog bo$ of
the Tools menu" +u$lic !ariables in a directly referenced proect are !isible to the directly referencing
proect, but +u$lic !ariables in a directly referencing proect are not !isible to a directly referenced
proect"
registry.n Jicrosoft =indows !ersion "7, OLE registration information and )le associations are stored in the
registration database, and program settings are stored in =indows system initiali+ation /"ini0 )les" .n
Jicrosoft =indows D3, the =indows registry ser!es as a central con)guration database for user,
application, and computer*speci)c information, including the information pre!iously contained in both
the =indows !ersion "7 registration database and "ini )les"
resource )leA )le in a Visual Basic proect with an "res )le name e$tension that can contain bitmaps, te$t strings, or
other data" By storing this data in a separate )le, you can change the information without editing your
code" Only one resource )le can be associated with a proect"
run*time errorAn error that occurs when code is running" A run*time error results when a statement attempts an
in!alid operation"
run time The time during which code is running" :uring run time, you can't edit the code"
scope:e)nes the !isibility of a !ariable, procedure, or obect" #or e$ample, a !ariable declared as +u$lic is
!isible to all procedures in all modules in a directly referencing proect unless %ption +ri*ate
2odule is in e
-
8/19/2019 Excel Macro Definitions
11/23
on a line" >ou can also use a line*continuation character //0 to continue a single logical line onto a
second physical line"
string comparisonA comparison of two se;uences of characters" 9se %ption Compare to specify binary or te$t
comparison" .n English*9"-", binary comparisons are case sensiti!eC te$t comparisons are not"
string constantAny constant /de)ned using the Const keyword0 consisting of a se;uence of contiguous characters
interpreted as the characters themsel!es rather than as a numeric !alue"
-tring data typeA data type consisting of a se;uence of contiguous characters that represent the characters
themsel!es rather than their numeric !alues" A Stringcan include letters, numbers, spaces, and
punctuation" The String data type can store )$ed*length strings ranging in length from 5 to
appro$imately 4 characters and dynamic strings ranging in length from 5 to appro$imately 2 billion
characters" The dollar sign /80 type*declaration character represents a String in Visual Basic"
string e$pressionAny e$pression that e!aluates to a se;uence of contiguous characters" Elements of a string e$pression
can include a function that returns a string, a string literal, a string constant, a string !ariable, a
string ariant, or a function that returns a string ariant /arT#pe 10"
string literalAny e$pression consisting of a se;uence of contiguous characters surrounded by ;uotation marks that
is literally interpreted as the characters within the ;uotation marks"
-ub procedureA procedure that performs a speci)c task within a program, but returns no e$plicit !alue"
A Su$ procedure begins with a Su$ statement and ends with an (nd Su$ statement"
synta$ checkingA feature that checks your code for correct synta$" .f the synta$ checking feature is enabled, a
message is displayed when you enter code that contains a synta$ error and the suspect code is
highlighted"
synta$ errorAn error that occurs when you enter a line of code that Visual Basic doesn't recogni+e"
ote that synta$ rules for indi!idual keywords are de)ned in the -ynta$ section of the associated Melp
topic" To get Melp on a keyword from within the de!elopment en!ironment, select the keyword and
press #7"
tab order The order in which the focus mo!es from one )eld to the ne$t as you press TAB or -M.#T%TAB"
time e$pressionAny e$pression that can be interpreted as a time" This includes any combination of time literals,
numbers that look like times, strings that look like times, and times returned from functions"
Times are stored as part of a real number" Values to the right of the decimal represent the time" #or
e$ample, midday /72?55 @"J"0 is represented by 5"3"
twipA unit of screen measurement e;ual to 7I25 point" A twip is a screen*independent unit used to ensure
that placement and proportion of screen elements in your screen application are the same on all
display systems" There are appro$imately 7FF5 twips to a logical inch or 348 twips to a logical
centimeter /the length of a screen item measuring one inch or one centimeter when printed0"
type*declaration characterA character appended to a !ariable name indicating the !ariable's data type" By default, !ariables are
of type ariant unless a correspondingDe5 type statement is present in the module"
type library
http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/
-
8/19/2019 Excel Macro Definitions
12/23
A )le or component within another )le that contains standard descriptions of e$posed obects,
properties, and methods that are a!ailable for Automation" Obect library )les /"olb0 contain type
libraries"
9nicode.nternational -tandards Organi+ation /.-O0 character standard" 9nicode uses a 74*bit /2*byte0 coding
scheme that allows for 43,34 distinct character spaces" 9nicode includes representations for
punctuation marks, mathematical symbols, and dingbats, with substantial room for future e$pansion"
uni!ersal date format The uni!ersal date format is Hyyyy*mm*dd hh?mm?ssH" Mowe!er, both the date component /Hyyyy*
mm*ddH0 and the time component /Hhh?mm?ssH0 can be represented separately"
user*de)ned typeAny data type de)ned using the T#pe statement" 9ser*de)ned data types can contain one or more
elements of any data type" Arrays of user*de)ned and other data types are created using
the Dim statement" Arrays of any type can be included within user*de)ned types"
!ariableA named storage location that can contain data that can be modi)ed during program e$ecution" Each
!ariable has a name that uni;uely identi)es it within its scope" A data type can be speci)ed or not"
Variable names must begin with an alphabetic character, must be uni;ue within the same scope, can't
be longer than 233 characters, and can't contain an embedded period or type*declaration character"
Variant data typeA special data type that can contain numeric, string, or date data as well as user*de)ned types and the
special !alues (mpt# and )ull" The ariantdata type has a numeric storage si+e of 74 bytes and can
contain data up to the range of a Decimal, or a character storage si+e of 22 bytes /plus string length0,
and can store any character te$t" The arT#pe function de)nes how the data in a ariant is treated"
All !ariables become ariantdata types if not e$plicitly declared as some other data type"
!ariant e$pressionAny e$pression that can e!aluate to numeric, string, or date data, as well as the special
!alues (mpt# and )ull"
watch e$pressionA user*de)ned e$pression that enables you to obser!e the beha!ior of a !ariable or e$pression" =atch
e$pressions appear in the =atch window of the Visual Basic Editor and are automatically updated
when you enter break mode" The Watch window displays the !alue of an e$pression within a gi!en
conte$t" =atch e$pressions are not sa!ed with your code"
+*order The !isual layering of controls on a form along the form's +*a$is /depth0" The +*order determines which
controls are in front of other controls"
Excel VBA Programming For Dummies
From Excel VBA Programming For Dummies, 4th Editionby John Walkenbach
The Visual Basic for Applications VBA! programming language lets you automate many aspects of Excel
by "riting #ub an$ Function proce$ures also kno"n as macros!% A goo$ kno"le$ge of VBA can sa&e
time an$ make you a much more pro$ucti&e Excel user%
'ommon VBA #tatements for Excel VBA Programming
http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://www.dummies.com/store/product/Excel-VBA-Programming-For-Dummies-4th-Edition.productCd-1119077397.htmlhttp://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://void%280%29/http://www.dummies.com/store/product/Excel-VBA-Programming-For-Dummies-4th-Edition.productCd-1119077397.html
-
8/19/2019 Excel Macro Definitions
13/23
The follo"ing table pro&i$es a list of commonly use$ VBA statements that you might use "hen creating
macros for Excel% For more information on a particular statement( consult Excel)s *elp system%
B3
Statement
What It Does
AppActi!ate Acti!ates an application window
Beep -ounds a tone !ia the computer's speaker
(all Transfers control to another procedure
(h:ir (hanges the current directory
(h:ri!e (hanges the current dri!e
(lose (loses a te$t )le
(onst :eclares a constant !alue
:ate -ets the current system date
:eclare :eclares a reference to an e$ternal procedure in a :ynamic Link
Library /:LL0
:elete-ettin
g
:eletes a section or key setting from an application's entry in the
=indows egistry
:im :eclares !ariables and /optionally0 their data types
:o*Loop Loops through a set of instructions
End 9sed by itself, e$its the programC also used to end a block of
statements that begin with .f, =ith, -ub, #unction, @roperty, Type,
or -elect
Erase e*initiali+es an array
Error -imulates a speci)c error condition
E$it :o E$its a block of :o*Loop code
E$it #or E$its a block of #or*e$t code
-
8/19/2019 Excel Macro Definitions
14/23
E$it #unction E$its a #unction procedure
E$it @roperty E$its a property procedure
E$it -ub E$its a subroutine procedure
#ile(opy (opies a )le
#or Each*
e$t
Loops through a set of instructions for each member of a collection
#or*e$t Loops through a set of instructions a speci)c number of times
#unction :eclares the name and arguments for a #unction procedure
Get eads data from a te$t )le
Go-ub"""et
urn
Branches to and returns from a procedure
GoTo Branches to a speci)ed statement within a procedure
.f*Then*Else @rocesses statements conditionally /the Else part is optional0
.nput H eads data from a se;uential te$t )le
ill :eletes a )le
Let Assigns the !alue of an e$pression to a !ariable or property
Line .nput H eads a line of data from a se;uential te$t )le
Load Loads an obect but doesn't show it
Lock"""9nloc
k
(ontrols access to a te$t )le
Jid eplaces characters in a string with other characters
Jk:ir (reates a new directory
ame enames a )le or directory
On Error Gi!es speci)c instructions for what to do in the case of an error
-
8/19/2019 Excel Macro Definitions
15/23
On"""Go-ub Branches, based on a condition
On"""GoTo Branches, based on a condition
Open Opens a te$t )le
Option Base (hanges the default lower limit for arrays
Option
(ompare
:eclares the default comparison mode when comparing strings
Option
E$plicit
#orces declaration of all !ariables in a module
Option
@ri!ate
.ndicates that an entire module is @ri!ate
@rint H =rites data to a se;uential )le
@ri!ate :eclares a local array or !ariable
@roperty Get :eclares the name and arguments of a @roperty Get procedure
@roperty Let :eclares the name and arguments of a @roperty Let procedure
@roperty -et :eclares the name and arguments of a @roperty -et procedure
@ublic :eclares a public array or !ariable
@ut =rites a !ariable to a te$t )le
aiseE!ent #ires a user*de)ned e!ent
andomi+e .nitiali+es the random number generator
e:im (hanges the dimensions of an array
em -peci)es a line of comments /same as an apostrophe N'0
eset (loses all open te$t )les
esume esumes e$ecution when an error*handling routine )nishes
-
8/19/2019 Excel Macro Definitions
16/23
m:ir emo!es an empty directory
-a!e-etting -a!es or creates an application entry in the =indows egistry
-eek -ets the position for the ne$t access in a te$t )le
-elect (ase @rocesses statements conditionally
-endeys -ends keystrokes to the acti!e window
-et Assigns an obect reference to a !ariable or property
-etAttr (hanges attribute information for a )le
-tatic :eclares !ariables at the procedure le!el so that the !ariables
retain their !alues as long as the code is running and the proect
hasn't been reset"
-top @auses the program
-ub :eclares the name and arguments of a -ub procedure
Time -ets the system time
Type :e)nes a custom data type
9nload emo!es an obect from memory
=hile"""=en
d
Loops through a set of instructions as long as a certain condition
remains true
=idth H -ets the output line width of a te$t )le
=ith Allows a shorthand way of accessing multiple properties for an
obect
=rite H =rites data to a se;uential te$t )le
VBA Functions for Excel VBA Programming
-
8/19/2019 Excel Macro Definitions
17/23
The VBA language contains a number of functions that you can use to buil$ co$e in Excel% The follo"ing
table pro&i$es $escriptions of the most useful functions% When "riting co$e( type the "or$ VBA follo"e$
by a perio$( an$ you)ll see a $rop+$rop list of these functions% #ee Excel)s *elp system for more $etails%
B3
Function
What It Does
Abs eturns the absolute !alue of a number
Array eturns a !ariant that contains an array
Asc (on!erts the )rst character of string to its A-(.. !alue
Atn eturns the arctangent of a number
(Bool (on!erts an e$pression to Boolean data type
(Byte (on!erts an e$pression to byte data type
((ur (on!erts an e$pression to currency data type
(:ate (on!erts an e$pression to date data type
(:bl (on!erts an e$pression to double data type
(:ec (on!erts an e$pression to decimal data type
(hoose -elects and returns a !alue from a list of arguments
(hr (on!erts an A-. !alue to a character
(.nt (on!erts an e$pression to integer data type
(Lng (on!erts an e$pression to long data type
(os eturns the cosine of a number
(reateObect (reates an OLE Automation obect
(-ng (on!erts an e$pression to single data type
(-tr (on!erts an e$pression to string data type
(ur:ir eturns the current path
-
8/19/2019 Excel Macro Definitions
18/23
-
8/19/2019 Excel Macro Definitions
19/23
#ormat(urre
ncy
eturns a number as a string, formatted as currency
#ormat:ateTi
me
eturns a number as a string, formatted as a date andIor time
#ormatumb
er
eturns a number as a formatted string
#ormat@erce
nt
eturns a number as a string, formatted as a percentage
#ree#ile eturns the ne$t )le number a!ailable for use by the Open
statement
GetAll eturns a list of key settings and their !alues /originally createdwith -a!e-etting0 from an applicationPs entry in the =indows
registry
GetAttr eturns a code representing a )le attribute
GetObect etrie!es an OLE Automation obect from a )le
Get-etting eturns a key setting !alue from an applicationPs entry in the
=indows registry
Me$ (on!erts from decimal to he$adecimal
Mour eturns the hour of a time
..f eturns one of two parts, depending on the e!aluation of an
e$pression
.nput eturns a speci)c number of characters from an open te$t )le
.nputBo$ :isplays a bo$ to prompt a user for input, and returns the !alue
entered
.n-tr eturns the position of a string within another string
.n-tre! eturns the position of a string within another string, beginning at
the back end of the string
.nt eturns the integer portion of a number
-
8/19/2019 Excel Macro Definitions
20/23
.sArray eturns True if a !ariable is an array
.s:ate eturns True if a !ariable is a date
.sEmpty eturns True if a !ariable has not been initiali+ed
.sError eturns True if an e$pression is an error !alue
.sJissing eturns True if an optional argument was not passed to a
@rocedure
.sull eturns True if an e$pression contains no !alid data
.sumeric eturns True if an e$pression can be e!aluated as a number
.sObect eturns True if an e$pression references an OLE Automation obect
oin eturns a string created by oining a number of substrings
contained in an array
LBound eturns the lower bound of an array
L(ase eturns a string con!erted to lowercase
Left eturns a speci)ed number of characters from the left of a string
Len eturns the length of a string, in characters
Loc eturns the current read or write position of a te$t )le
LO# eturns the number of bytes in an open te$t )le
Log eturns the natural logarithm of a number
LTrim eturns a copy of a string with no leading spaces
Jid eturns a speci)ed number of characters from a string
JidB eturns a speci)ed number of bytes from a speci)ed position in a
string string
Jinute eturns the minute of a time
-
8/19/2019 Excel Macro Definitions
21/23
Jonth eturns the month of a date
Jonthame eturns a string indicating the speci)ed month
JsgBo$ :isplays a modal message bo$ and returns the .: of the button
clicked
ow eturns the current system date and time
Oct (on!erts from decimal to octal
eplace eturns a string in which one substring is replaced with another
GB eturns a number representing an GB color !alue
ight eturns a speci)ed number of characters from the right of a string
nd eturns a random number between 5 and 7
ound ounds a number to a speci)c number of decimal places
Trim eturns a copy of a string with no trailing spaces
-econd eturns the second of a time
-eek eturns the current position in a te$t )le
-gn eturns an integer that indicates the sign of a number
-hell uns an e$ecutable program
-in eturns the sine of a number
-pace eturns a string with a speci)ed number of spaces
-plit eturns an array consisting of a number of substrings
-;r eturns the s;uare root of a number
-tr eturns a string representation of a number
-tr(omp eturns a !alue indicating the result of a string comparison
-
8/19/2019 Excel Macro Definitions
22/23
-tr(on! eturns a string !ariant con!erted as speci)ed
-tring eturns a repeating character or string
-tre!erse eturns the characters of a string in re!erse order
-witch E!aluates a list of e$pressions and returns a !alue associated with
the )rst e$pression in the list that is True
Tab @ositions output in an output stream
Tan eturns the tangent of a number
Time eturns the current system time
Timer eturns the number of seconds since midnight
Time-erial eturns the time for a speci)ed hour, minute, and second
TimeValue (on!erts a string to a time serial number
Trim eturns a string without leading and spaces and replaces multiple
spaces with a single space
Typeame eturns a string that describes the data type of a !ariable
9Bound eturns the upper bound of an array
9(ase (on!erts a string to uppercase
Val eturns the numbers contained in a string
VarType eturns a !alue indicating the subtype of a !ariable
=eekday eturns a number representing a day of the week
=eekday
ame
eturns a string indicating the speci)ed weekday
>ear eturns the year of a date
-
8/19/2019 Excel Macro Definitions
23/23