Excel VBA Flashcards

1
Q

What statement must be added in the module to ensure that variable declaration is required?

A

Option Explicit

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the excel object model?

A

a clearly defined set of objects that are structured by their relationship to each other

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are two ways to reference a worksheet in vba?

A

By it’s worksheet name or by the index number:
Worksheets(1).Select
Worksheets(“MySheet”).Select

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is object property?

A

An object property is a characteristic of an object. For example:
Worksheet(“Sheet1”).Name = “MySheet”
In the above code the “Name” is property of the worksheet object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are methods in VBA?

A

Methods are the actions the can be performed on an object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the cells property?

A

The cells property allows the user to specify a value in worksheet object. It takes two inputs, a row and column index, in order to determine the cell reference in the workbook. For example:
Worksheets(“Sheet1”).Cells(1, 2) = 9
The above code specifies that cell B1 ( row 1 column 2) = 9

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are two ways to test an expression

A

Use the debug.print function in your sub procedure followed by the expression as shown below:
Debug.Print Range(“A1”).Value
Or use the immediate window using syntax shown below:
? Range(“A1”).Value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

True or False? Are variable names case-sensitive in VBA?

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does a data type specify?

A

Specifies how data is stored in memory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is string data type used for?

A

A string data type is used for storing text

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What data type is typically used for processing numbers without losing any precision?

A

The double data type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What data type is typically used for processing numbers for values less than 32,767?

A

The Long data type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

If a data type is not declared what is the default data type assigned?

A

The variant data type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a local variable?

A

a variable declared within a procedure. When the procedure ends, the variable no longer exists.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are public variables?

A

public variables are variables that are available to all the procedures in all the VBA modules.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is an array and how is it declared in vba?

A
a group of elements of the same type that have a common name. Declared using the following syntax:
Dim MyArray(100) As Interger. The 100 within the parenthesis refers to the array size.
17
Q

What is a dynamic array and how is it declared in vba?

A
A dynamic array doesn't have a preset number of elements. It is declared using the following syntax:
Dim MyArray( ) As Integer.
18
Q

What statement is used when declaring a dynamic array in VBA?

A
In order to use a dynamic array in your code, the ReDim statement must be used
ReDim MyArray (1 to x).
19
Q

When declaring the array size with dynamic arrays how do you ensure the array’s existing dimensions are not destroyed?

A

Use the preserve statement in conjunction with the ReDim statement as shown below:
ReDim Preserve MyArray (1 to y)

20
Q

How do you use a worksheet function in VBA?

A

Worksheet function can by using the following statement:
Application.WorksheetFunction.Sum
Sum is an example of a function found in the excel application

21
Q

What is the syntax for the MsgBox Function in VBA?

A

MsgBox(prompt[, buttons][,title][,helpfile,context])

prompt: Required. The message display in the pop-up display
buttons: Optional. A value that specifies which buttons and which icons, if any appear in the message box. Use built-in constants - for example, vbYesNo.

Title: Optional. The text that appears in the message box’s title bar. The default is Microsoft excel.