Chapter 7. Built-in Functions and Statements

VBA has a large number of built-in functions and statements. For possible reference, Table 7-1 shows the VBA functions, and Table 7-2 shows the statements. We will take a look at a few of the more commonly used functions and statements for programming Excel VBA in this chapter and Chapter 8.

To help simplify the exposition, we will follow Microsoft’s lead and use square brackets to indicate optional parameters. Thus, for instance, the second parameter in the following procedure is optional:

Sub ChangeFormat(FontName [, FontSize])

Note that we have also omitted the data type declarations, which will be discussed separately.

Table 7-1. VBA Functions[1]

Abs

DoEvents

IsEmpty

Right

Array

Environ

IsError

RightB

Asc

EOF

IsMissing

Rnd

AscB

Error

IsNull

Round*

AscW

Exp

IsNumeric

RTrim

Atn

FileAttr

IsObject

Second

CallByName*

FileDateTime

Join*

Seek

Cbool

FileLen

Lbound

Sgn

Cbyte

Filter*

Lcase

Shell

Ccur

Fix

Left

Sin

Cdate

Format

LeftB

SLN

CDbl

FormatCurrency*

Len

Space

Cdec

FormatDateTime*

LenB

Spc

Choose

FormatNumber*

LoadPicture

Split*

Chr

FormatPercent*

Loc

Sqr

ChrB

FreeFile

LOF

Str

ChrW

FV

Log

StrComp

Cint

GetAllSettings

Ltrim

StrConv

CLng

GetAttr

Mid

String

Command

GetAutoServerSettings

MidB

StrReverse*

Cos

GetObject

Minute

Switch

CreateObject

GetSetting

MIRR

SYD

CSng

Hex

Month

Tab

CStr

Hour

MonthName*

Tan

CurDir

Iif

MsgBox

Time

Cvar

IMEStatus ...

Get Writing Excel Macros with VBA, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.