← Interview & exam prep
Technical interview questions
VBA interview questions
13 questions from beginner to advanced, each with the correct answer and a one-line explanation of why. Study them here, or take them as a timed test.
13 questionsBeginner 7 · Intermediate 6Answers + explanations
Beginner 7 questions
1Which keyword DECLARES a variable in VBA?
- Var
- Set
- Let
- Dim
- Declare
Show answerHide answer
D · Dim Dim declares a variable (e.g., Dim i As Long).
2To assign an OBJECT reference to a variable you use…
- Set
- Assign
- Let
- =
- Bind
Show answerHide answer
A · Set Objects require Set (e.g., Set ws = Worksheets(1)); scalars use a plain =.
3A comment in VBA begins with…
- #
- '
- /*
- //
- --
Show answerHide answer
B · ' An apostrophe starts a comment; the rest of the line is ignored.
4Option Explicit forces you to…
- Declare every variable before use
- Use early binding
- Turn off screen updating
- Compile faster
- Use error handling
Show answerHide answer
A · Declare every variable before use Option Explicit prevents typos by requiring all variables to be declared.
5Which event fires when a cell value on a sheet changes?
- Worksheet_Change
- Worksheet_Activate
- OnEdit
- Workbook_Open
- Worksheet_Calculate
Show answerHide answer
A · Worksheet_Change Worksheet_Change runs when the user edits a cell on that sheet.
6To loop over every cell in a range, use…
- GoTo
- DoEvents
- Select Case
- With rng
- For Each cell In rng
Show answerHide answer
E · For Each cell In rng For Each … In iterates a collection such as the cells of a range.
7To stop the screen from flickering during a macro, set…
- Application.Calculation = False
- Application.ScreenUpdating = False
- Range.Clear
- DoEvents
- Application.Quit
Show answerHide answer
B · Application.ScreenUpdating = False ScreenUpdating = False suppresses redraws (remember to set it back to True).
Intermediate 6 questions
8A Function differs from a Sub because a Function…
- Is public only
- Runs faster
- Cannot take arguments
- Cannot be called
- Returns a value
Show answerHide answer
E · Returns a value A Function returns a value to the caller; a Sub performs actions without returning one.
9ByVal passes an argument as…
- A copy of the value
- An object only
- Nothing
- A reference to the original
- A global
Show answerHide answer
A · A copy of the value ByVal passes a copy, so changes don't affect the caller; ByRef passes a reference.
10Runtime error handling in VBA uses…
- catch { }
- On Error GoTo label
- Try / Catch
- On Error Ignore
- IFERROR
Show answerHide answer
B · On Error GoTo label On Error GoTo redirects execution to a labelled handler; Resume/Resume Next control flow after.
11Early binding (vs late binding) means…
- Running without references
- Declaring As Object
- Binding at shutdown
- Setting a library reference and typed variables at compile time (IntelliSense)
- Using CreateObject only
Show answerHide answer
D · Setting a library reference and typed variables at compile time (IntelliSense) Early binding references the type library up front, enabling IntelliSense and compile-time checks.
12To get the actually-used area of a sheet, use…
- Range("A1")
- ActiveCell
- Worksheet.UsedRange
- Cells.Count
- Selection
Show answerHide answer
C · Worksheet.UsedRange UsedRange returns the rectangle spanning the used cells of the worksheet.
13A Scripting.Dictionary is preferred over a Collection when you need…
- Less memory always
- Keyed lookup with .Exists and unique keys
- No references
- Charts
- Ordered numbers
Show answerHide answer
B · Keyed lookup with .Exists and unique keys Dictionaries support key existence checks and value updates by key, unlike the basic Collection.
What changed lately? Latest VBA & Macros news, releases & questions →
More technical interview questions