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 statement pauses execution for a specified number of milliseconds?
Answer: Application.Wait Now + TimeValue("00:00:01")
Application.Wait accepts a future time value; to pause for 1 second you pass Now plus a 1-second TimeValue.
What is the purpose of the 'Option Explicit' statement at the top of a VBA module?
Answer: Forces all variables to be declared before use
Option Explicit requires every variable to be declared with Dim, preventing typos from creating unintended new variables.
Which method deletes all content AND formatting from a range in VBA?
Answer: Range.Clear
Range.Clear removes cell values, formulas, formatting, comments, and hyperlinks — a complete reset.
In VBA, which operator is used for string concatenation?
Answer: &
The & operator concatenates strings in VBA; while + can also work, & is preferred because it avoids type ambiguity.
What does the 'ByVal' keyword mean in a VBA procedure parameter?
Answer: A copy of the argument is passed; changes don't affect the original
ByVal passes a copy of the variable, so any changes made inside the procedure do not affect the caller's variable.
Which VBA method is used to find the last used row in a column efficiently?
Answer: Cells(Rows.Count, 1).End(xlUp).Row
Starting from the bottom of the column and pressing End+Up finds the last non-empty cell, giving the true last used row.
What VBA object model component would you use to open a file dialog so users can select a file?
Answer: Application.GetOpenFilename
Application.GetOpenFilename displays a file open dialog and returns the selected file path without actually opening the file.