1. B
Option Explicit forces explicit declaration of all variables, helping catch errors related to undeclared variables.
2. A
The correct syntax to declare a variable in VBA is `Dim variableName As DataType`.
3. A
The Workbook_Open event triggers a macro when a workbook is opened.
4. A
Using `For Each ws In Worksheets` allows iteration through all worksheets in a workbook.
5. A
The “Do While” loop repeats the code as long as the condition remains true.
6. D
The formula `ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row` finds the last used row in the active worksheet.
7. A
You can change a cell’s background color by setting the `Interior.Color` property using RGB values.
8. B
The `Worksheet` object is used to manipulate a specific worksheet in VBA.
9. A
The `ActiveSheet` refers to the currently active (selected) worksheet.
10. A
The `On Error Resume Next` statement allows the macro to continue even after an error occurs.
11. A
The `Range` object refers to a single cell or a group of cells in a worksheet.
12. C
The `Workbooks.Open` method is used to open a workbook.
13. B
You hide a worksheet using the `Sheets.Visible = xlHidden` property.
14. A
The default value for the “Visible” property of a worksheet is `xlVisible`.
15. A
You declare an array in VBA using `Dim arr(1 To 10) As Integer`.
16. B
You can assign a macro to a button by right-clicking the button and selecting “Assign Macro.”
17. A
The `MsgBox` function displays a message box to the user.
18. A
The `With…End With` block allows you to perform multiple operations on a single object without repeatedly referencing the object.
19. C
You can reference a specific cell either using `Range(“A1”)` or `Cells(1, 1)` in VBA.
20. A
The correct syntax for creating a function in VBA is `Function FunctionName() As DataType`.
21. A
The `Worksheet.Protect` method is used to prevent the user from modifying a worksheet.
22. A
You write a formula in a cell by using `Cells(1, 1).Formula = “=SUM(A2:A10)”`.
23. C
The `Exit For` statement is used to exit a loop in VBA.
24. B
The `Range.Copy` method copies data from one range to another.
25. C
You display a user-defined dialog box by creating and showing a `UserForm`.
26. A
The correct property to set or return the font size is `Font.Size`.
27. C
You save a workbook with the `Workbook.SaveAs` method.
28. B
You select a range using `Range(“A1:B10”).Select`.
29. B
The `Do Until` loop repeats until the condition becomes true.
30. D
All of the listed methods can be used to change the font color of a cell.
31. D
The `Application.Wait` method pauses the macro for a specified amount of time.
32. A
You reference a cell using `Cells(Row, Column)`.
33. A
You create a new worksheet using the `Sheets.Add` method.
34. A
The `vbYesNo` constant creates a message box with Yes and No buttons.
35. B
The `SaveChanges:=False` argument ensures that the workbook is closed without saving changes.
Prepare for the Excel VBA exam with our free practice test modules. Each quiz covers key topics to help you pass on your first try.