Excel VBA Flashcards
7 cards from real Excel VBA practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.
Read the first 7 Excel VBA flashcards as text
Which VBA collection object contains all open workbooks in the current Excel instance?
Answer: Workbooks
The Workbooks collection is a property of the Application object and holds all currently open Workbook objects.
What does the MsgBox function return when the user clicks the Cancel button?
Answer: vbCancel (2)
MsgBox returns the VBA constant vbCancel, which has an integer value of 2, when Cancel is clicked.
Which statement is used to define a reusable block of code that does NOT return a value in VBA?
Answer: Sub
A Sub procedure performs actions but does not return a value, unlike a Function which returns a result.
How do you copy a range in VBA without including the clipboard (direct value copy)?
Answer: destRange.Value = sourceRange.Value
Assigning .Value directly between ranges transfers data without using the clipboard or triggering a copy animation.
What does the Cells property return when called as Cells(2, 3) on a worksheet?
Answer: The cell in row 2, column 3 (C2)
Cells(row, column) uses numeric row and column indices, so Cells(2,3) refers to row 2, column C — cell C2.
Which VBA function extracts a substring from the right side of a string?
Answer: Right
Right(string, length) returns the specified number of characters from the rightmost end of the string.
What happens when you use 'ReDim Preserve' on a dynamic array in VBA?
Answer: The array is resized while keeping existing data
ReDim Preserve resizes a dynamic array and retains the values already stored in it, unlike plain ReDim which resets them.