AIN3701 Assignment 3 Questions and Correct
Answers (Verified Answers) Plus Rationale
2027 Q&A| Instant Download Pdf
1. What is the primary purpose of Option Explicit in VBA?
A. To automatically format variables
B. To prevent the use of loops
C. To require variables to be declared before use
D. To execute a procedure automatically
Answer: C. To require variables to be declared before use
Rationale: Option Explicit requires every variable to be explicitly
declared with statements such as Dim. This reduces errors caused by
misspelled or unintentionally created variable names and promotes
better VBA programming practice.
2. Which VBA statement is used to declare a variable?
A. Define
B. Dim
,C. Var
D. Declare
Answer: B. Dim
Rationale: The Dim statement is the standard VBA command for
declaring variables. For example, Dim TotalSales As Currency creates a
variable named TotalSales that can store currency values.
3. Which VBA data type is most appropriate for storing a whole
number such as the number of transactions?
A. String
B. Boolean
C. Integer
D. Date
Answer: C. Integer
Rationale: An Integer data type is designed for whole-number values.
For larger whole-number ranges, Long is generally preferable, but
Integer is conceptually appropriate for ordinary whole-number values
within its range.
4. Which VBA data type is most appropriate for storing monetary
values?
,A. Currency
B. Boolean
C. String
D. Date
Answer: A. Currency
Rationale: The Currency data type is specifically designed for financial
calculations. It provides fixed-point precision that helps minimise
rounding problems in monetary calculations.
5. Which statement correctly assigns the value 2500 to a variable
called Revenue?
A. Revenue = 2500
B. Set Revenue = 2500
C. Dim Revenue = 2500
D. Revenue := 2500
Answer: A. Revenue = 2500
Rationale: In VBA, the assignment operator is =. The Set keyword is
normally used when assigning object references, rather than ordinary
numeric values.
6. What is the main purpose of a For...Next loop?
, A. To declare a variable
B. To repeat a set of instructions a specified number of times
C. To create a worksheet
D. To format a workbook
Answer: B. To repeat a set of instructions a specified number of times
Rationale: A For...Next loop repeatedly executes a block of code while
a counter progresses through a specified range of values. It is useful
when processing multiple rows of spreadsheet data.
7. Which VBA statement is commonly used to determine the last
populated row in a worksheet column?
A. Cells.LastRow
B. Rows.End
C. Cells(Rows.Count, 1).End(xlUp).Row
D. Worksheet.LastCell()
Answer: C. Cells(Rows.Count, 1).End(xlUp).Row
Rationale: This expression starts at the bottom of column A and
moves upward to the last populated cell. The .Row property returns its
row number.
8. What does the Long data type store?
Answers (Verified Answers) Plus Rationale
2027 Q&A| Instant Download Pdf
1. What is the primary purpose of Option Explicit in VBA?
A. To automatically format variables
B. To prevent the use of loops
C. To require variables to be declared before use
D. To execute a procedure automatically
Answer: C. To require variables to be declared before use
Rationale: Option Explicit requires every variable to be explicitly
declared with statements such as Dim. This reduces errors caused by
misspelled or unintentionally created variable names and promotes
better VBA programming practice.
2. Which VBA statement is used to declare a variable?
A. Define
B. Dim
,C. Var
D. Declare
Answer: B. Dim
Rationale: The Dim statement is the standard VBA command for
declaring variables. For example, Dim TotalSales As Currency creates a
variable named TotalSales that can store currency values.
3. Which VBA data type is most appropriate for storing a whole
number such as the number of transactions?
A. String
B. Boolean
C. Integer
D. Date
Answer: C. Integer
Rationale: An Integer data type is designed for whole-number values.
For larger whole-number ranges, Long is generally preferable, but
Integer is conceptually appropriate for ordinary whole-number values
within its range.
4. Which VBA data type is most appropriate for storing monetary
values?
,A. Currency
B. Boolean
C. String
D. Date
Answer: A. Currency
Rationale: The Currency data type is specifically designed for financial
calculations. It provides fixed-point precision that helps minimise
rounding problems in monetary calculations.
5. Which statement correctly assigns the value 2500 to a variable
called Revenue?
A. Revenue = 2500
B. Set Revenue = 2500
C. Dim Revenue = 2500
D. Revenue := 2500
Answer: A. Revenue = 2500
Rationale: In VBA, the assignment operator is =. The Set keyword is
normally used when assigning object references, rather than ordinary
numeric values.
6. What is the main purpose of a For...Next loop?
, A. To declare a variable
B. To repeat a set of instructions a specified number of times
C. To create a worksheet
D. To format a workbook
Answer: B. To repeat a set of instructions a specified number of times
Rationale: A For...Next loop repeatedly executes a block of code while
a counter progresses through a specified range of values. It is useful
when processing multiple rows of spreadsheet data.
7. Which VBA statement is commonly used to determine the last
populated row in a worksheet column?
A. Cells.LastRow
B. Rows.End
C. Cells(Rows.Count, 1).End(xlUp).Row
D. Worksheet.LastCell()
Answer: C. Cells(Rows.Count, 1).End(xlUp).Row
Rationale: This expression starts at the bottom of column A and
moves upward to the last populated cell. The .Row property returns its
row number.
8. What does the Long data type store?