Excel VBA Data Manipulation & Arrays Flashcards
6 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 6 Excel VBA Data Manipulation & Arrays flashcards as text
How do you declare a dynamic array in VBA?
Answer: Dim arr() As Integer
A dynamic array is declared with empty parentheses (Dim arr() As Integer) and resized later with ReDim.
Which VBA statement resizes a dynamic array while preserving existing data?
Answer: ReDim Preserve arr(20)
ReDim Preserve resizes the array to the new size while keeping all previously stored values intact.
What does the LBound() function return for an array?
Answer: The first valid index
LBound() returns the lowest subscript (first valid index) of the specified array dimension.
In VBA, how do you declare a two-dimensional array with 3 rows and 4 columns?
Answer: Dim arr(2, 3) As Integer
Since VBA arrays are zero-based by default, Dim arr(2, 3) creates indices 0–2 and 0–3, giving 3 rows and 4 columns.
Which built-in VBA function splits a string into an array using a delimiter?
Answer: Split()
The Split() function divides a string by a specified delimiter and returns a zero-based string array.
What is the default lower bound for VBA arrays?
Answer: 0
VBA arrays are zero-based by default, meaning index 0 is the first element unless Option Base 1 is set.