0% found this document useful (0 votes)
53 views

VBA Data Type

This document discusses fundamentals of programming with VBA, including exit statements and VBA data types. It explains that exit statements can be used to exit for, next, do, and while loops as well as sub and function procedures. The document also lists VBA's built-in data types, such as boolean, integer, long integer, single and double precision, currency, date, object, string, and variant, and provides the storage size and value ranges for each data type. Unless declared, variables default to the variant type.

Uploaded by

Jaroslav Kuruc
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views

VBA Data Type

This document discusses fundamentals of programming with VBA, including exit statements and VBA data types. It explains that exit statements can be used to exit for, next, do, and while loops as well as sub and function procedures. The document also lists VBA's built-in data types, such as boolean, integer, long integer, single and double precision, currency, date, object, string, and variant, and provides the storage size and value ranges for each data type. Unless declared, variables default to the variant type.

Uploaded by

Jaroslav Kuruc
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

CHAPTER 2

FUNDAMENTALS OF PROGRAMMING WITH VBA

27

using the Exit For (from a For...Next loop or For Each...Next loop) or Exit Do
(from a Do While... loop). The Exit statement will normally be located within an
If statement. For example,
If CellContenkValue c= 0 Then Exit For

Use the Exit Sub or Exit Function to exit from a procedure. Again, the Exit
statement will normally be located within an If statement.
Exit statements can appear as many times as needed within a procedure.

VBA Data Types


VBA uses a range of different data types. Table 2-6 lists the built-in data
types. Unless you declare a variable's type, VBA will use the Variant type. You
can save memory space if your procedure deals only with integers, for example,
by declaring the variable as Integer. The keyword Dim is used to declare a
variable's data type, as will be described in a following section.
Table 2-6. VBA's Built-in Data Types
Storage Required
Range of Values
True or False
Boolean (Logical) 2 bytes
-32,768 to 32,767
Integer
2 bytes
-2,147,483,648 to 2,147,483,647
Long integer
4 bytes
-3.402823E+38 to -1.401298E-45
Single precision
4 bytes
for negative values; 1.401298E-45
to 3.402823E+38 for positive
values
8 bytes
-1.797693 13486232E+308 to
Double precision
-4.9406564584 1247E-324 for
negative values;
4.94065645841247E-324 to
1.797693 13486232E+308 for
positive values
8 bytes
-922,337,203,685,477.5808 to
Currency
922,337,203,685,477.5807
8 bytes
Date
Object
Any Object reference
4 bytes
String
1 bytekharacter
Variant
Any numeric value up to the
16 bytes
+ 1 bvte/character range of a Double or anv text

Data Type

You might also like