VBA MCQs

VBA MCQs

Our experts have gathered these VBA MCQs through research, and we hope that you will be able to see how much knowledge base you have for the subject of VBAX by answering these 100+ multiple-choice questions.
Get started now by scrolling down!

1: What does VBA mean?

A.   Visual Basic Answers

B.   Visual By Arithmetic

C.   Visual By Algorithms

D.   Visual Basic for Applications

2: Using the Select Case construct is ideal when:

A.   Too many if-then statements have already been used

B.   An action is taken regardless of the value a variable

C.   A variable is a Boolean type

D.   A variable can take on multiple values

3: To obtain the value of the number of characters used in a textbox field on a form, which snippet of VBA code would you use?

A.   Len(CStr(Forms!DataEntryfrm.Text11.Value))

B.   Spaces(Forms!DataEntryfrm.Text11.Value)

C.   Char(Forms!DataEntryfrm.Text11.Value)

D.   Length(CStr(Forms!DataEntryfrm.Text11.Value))

4: How do you figure out the number of items in a collection?

A.   (none of these are correct)

B.   Using Items property

C.   Using Count property

D.   Using Ubound property

E.   Using Contains method

5: Correct this statement to start a 5-iteration loop: For x = 1 to 10 Step -2

A.   For x = 1 to 5 Step 2

B.   For x = 1 to 10 Step 2

C.   For x = 1 to 5 Step 5

D.   For x = 1 to 10 Step 5

6: To save a VBA project with an Excel workbook, the workbook must be saved as what type of file?

A.   xlsm

B.   xlsx

C.   xlv

D.   xlsv

7: Which of the following do not work on Excel on Mac

A.   ActiveX Controls

B.   Form Controls

8: What is difference between a sub routine and a function.

A.   Function can return a value.

B.   Sub routine can return a value.

9: What is a macro used for?

A.   To link Excel files together

B.   To automatically complete a series of Excel steps

C.   To create buttons and forms in Excel

D.   To access programs in Excel

10: What does VBA stand for

A.   Virtual Basic for Advanced programming

B.   Visual Basic Applied

C.   Visual Basic for Applications

D.   Very Basic Applications

11: Which of the following snippets of VBA code is not a loop?

A.   Select Case... Case... Case Else... End Select

B.   Do Until... Loop

C.   For Each.. Next

D.   Do While... Loop

12: You can use VBA to connect to a database in SQL Server using:

A.   Just a simple SQL statement

B.   an ethernet cable

C.   an ADODB.Connection

D.   Access as a go-between

13: To comment a block of code, you must first:

A.   Turn on Num Lock

B.   Activate the Edit toolbar in the Visual Basic Editor

C.   Turn on Caps Lock

D.   Restart Excel

14: How do you declare the variable myvar as an integer?

A.   Document myvar as an Integer

B.   Dim myvar As Integer

C.   Declare myvar is an Integer

15: The 'not equal to' operator is:

A.   >=

B.   <>

C.   ==

D.   <=

16: Which of the following would you begin a comment line with?

A.   Double quote

B.   Single quote

C.   Equal sign

D.   Underscore

17: On July 4, 2013, What will be displayed in the message box from the following statement: MsgBox(Format(Now,"mm-dd-yyyy"))

A.   07-04-2013

B.   7-4-2013

C.   7/4/2013

D.   07/04/2013

18: To force all variables is a VBA project to be declared, which must be stated in a module?

A.   Option Explicit

B.   Option Variables

C.   Option Implicit

D.   Option Declare

19: True or False? It is possible to name a Sub with a string containing a space.

A.   False

B.   True

20: True or False? Commenting at the end of a line of code is permissible.

A.   True

B.   False

21: To continue to run code even if a line of code causes an error, choose the VBA code to continue to the next line of code.

A.   Goto

B.   Next

C.   On Error Resume

D.   On Error Resume Next

22: What do you need to select to set the developer mode?

A.   Show developer tab in the Ribbon

B.   Show mini toolbar on selection

C.   Show visual basic options menu

D.   Show macro code settings

23: Which of the following is not a VBA data type?

A.   Date

B.   Integer

C.   VarChar

D.   Long

E.   String

24: The tab order in a user form:

A.   Allowing the controls to be sorted alphabetically within the user form

B.   ________ is a way to control the order in which the controls are selected using the TAB key.

C.   Requireing the user to assign numbers to each control on the user form

D.   Arranging the worksheets in an Excel workbook

25: You've created a user form named 'Entry_Form'. To make the user form appear, use which of the following statements?

A.   Entry_Form.Appear

B.   UserForm.Entry_Form.Run

C.   UserForm.Load

D.   Entry_Form.Show

26: The shortcut keystroke to open the VBA IDE is:

A.   F10

B.   Alt+F11

C.   Alt+Ctrl+F8

D.   Alt+V

27: Choose the VBA code that will allow you to obtain information about an error.

A.   Err.Type

B.   Err.Description

C.   Err.Title

D.   Err.Name

28: Is it possible to create an array with the lowerbound being two?

A.   Sometimes

B.   No

C.   Yes

29: Which of these is not a Visual Basic object?

A.   Sheets

B.   Range

C.   Selection

D.   FontSize

30: Declaring a public variable allows the user to..

A.   Use the variable anywhere in Excel

B.   Use the variable as a named range in Excel

C.   Use the variable only within the module in which the variable was declared

D.   Use the variable anywhere in the project in which the variable was declared

31: What does a VBA macro consist of?

A.   User instructions and Excel functions

B.   Computer code that performs some actions on or with objects

C.   Macro instructions that direct the user application and provide help to the user

D.   Excel functions

32: The RowSource property of a Combo Box control allows the user to:

A.   control where the output of selected item should go

B.   define the list of items, from a range of cells, to appear in a drop-down list

C.   have only one item in the drop-down list

D.   restrict which row of cells can be the source of input items for the drop-down list

33: Which worksheet event can be used to run a procedure upon deleting the contents of a cell?

A.   Click

B.   Calculate

C.   Change

D.   Activate

34: In the statement x = "4" + "5"', x = ?

A.   1

B.   9

C.   -1

D.   45

35: What is the shortcut keystroke to debug VBA code one line at a time?

A.   F5

B.   Alt+F5

C.   F8

D.   Ctrl+F8

36: The way to pass the latest values of variables between functions and procedures is identified as:

A.   (none of these)

B.   ByRef

C.   ByUpdate

D.   ByChange

37: Which of the following VBA windows shows the code of the active object?

A.   Properties window

B.   Code window

C.   Immediate window

D.   Explorer Window

38: Which of these statements will start a loop of exactly 20 iterations?

A.   For i = 1 to 21

B.   For i = 2 to 40

C.   For i = 2 to 22

D.   For i = 2 to 40 Step 2

39: Dim a,b as integer What is the type of a?

A.   variant

B.   integer

40: The statement 'Dim a, b as Single' declares the variables a and b as what variable types?

A.   a as Double, b as Single

B.   a as Single; b as Single

C.   a as Double; b as Double

D.   a as Variant; b as Single

41: If you want to create a definition for a custom object in VBA, which of the following would be the best choice to insert into your project?

A.   Class Module

B.   Module

C.   UserForm

D.   Procedure

42: What is the property of a cell that allows you to set the font color of the contents?

A.   Cell.Color

B.   Font.Color

C.   FontColor

D.   CellColor

43: Which of the following functions do not perform a calculation

A.   IPmt

B.   Exp

C.   Sqr

D.   Val

44: What does the DoEvents do?

A.   Allows operation system to process other events

B.   Runs all events (built-in or custom) in a vb project

C.   Declare a new event that can be fired from code

D.   Runs all Excel events in a vb project

45: Choose the VBA code that switches control from the application to the OS.

A.   Wait

B.   Goto

C.   DoEvents

D.   Continue

46: Which of the following actions will NOT cause a macro to run in Excel?

A.   Add a new worksheet

B.   Open a workbook

C.   (all of these will NOT cause a macro to run in Excel)

D.   Click on a picture

47: What is the difference between activating and initializing a user form?

A.   Activate will always run when showing a user form whereas Initialize will only run when showing a user form that has not been stored in memory.

B.   There are no differences. Both are run whenever a user form is shown.

C.   There are differences only if Option Explicit is stated.

D.   Initialize will always run when showing a user form whereas Activate will only run when showing a user form that has not been stored in memory.

48: To change a comment in cell A1, which will do the job?

A.   Range("A1").Comment.Text("My Comment")

B.   Range("A1").Comment("My Comment")

C.   Range("A1") = "My Comment"

D.   Range("A1").Text("My Comment")

49: Combine into one line: If x > 5 Then y = x - 5 End If

A.   y = x - 5 If x > 5

B.   If x > 5 Then y = x - 5

C.   If x > 5, y = x - 5

D.   If x > 5 Then y = x - 5 End If

50: To change the text displayed in a label on a form, choose the VBA code that will allow you to update the property.

A.   Me.Label3.Value = "Hello"

B.   Me.Label3.Caption = "Hello"

C.   Me.Label3 = "Hello"

D.   Me.Label3.Text = "Hello"