Freshers Registration

VBA Quiz – VBA Multiple Choice Questions and Answers

VBA Quiz

VBA Quiz – VBA Multiple Choice Questions and Answers: Are you ready to take a VBA quiz? If so, you’ll find a series of VBA quiz questions in this article that are often asked in various interviews and placement exams. In addition, VBA multiple-choice questions and answers are provided to help you identify the correct answers and prepare for an online VBA programming quiz. Furthermore, if you consider yourself an expert in VBA concepts, the VBA quiz questions and answers provided here can help you enhance your existing knowledge. We sincerely hope you make good use of the VBA MCQ questions and answers that are presented here.

VBA Quiz

Further, before moving ahead and checking the VBA Multiple Choice Questions, kindly know the concept of VBA through this section. VBA (Visual Basic for Applications) is a programming language that is widely used for automating tasks in Microsoft Office applications, such as Excel, Word, and PowerPoint. It is a powerful tool that allows users to create custom macros and automate repetitive tasks, thereby saving time and increasing efficiency. VBA is an object-oriented language that is based on the Visual Basic programming language and is integrated into the Microsoft Office suite of applications. With VBA, users can perform complex calculations, generate reports, and manipulate data, among other things. VBA is a valuable skill for anyone who uses Microsoft Office regularly and is looking to streamline their workflow.

Join Telegram Join Telegram
Join Whatsapp Groups Join Whatsapp

VBA Multiple Choice Questions

Quiz Name VBA Quiz
Exam Type MCQ (Multiple Choice Questions)
Category Technical Quiz
Mode of Quiz Online

Top 64 VBA MCQ Questions | VBA Quiz

1. What does VBA stand for?

A) Visual Basic Analysis
B) Visual Basic Application
C) Visual Basic Algorithm
D) Visual Basic Automation

Answer: B) Visual Basic Application

Explanation: VBA stands for Visual Basic Application, which is a programming language used to automate tasks in Microsoft Office applications.

2. Which of the following is NOT a feature of VBA?

A) Object-Oriented Programming
B) Dynamic Typing
C) Debugging Tools
D) Conditional Formatting

Answer: D) Conditional Formatting

Explanation: Conditional Formatting is not a feature of VBA. It is a feature of Excel that allows you to format cells based on certain conditions.

3. What is a macro in VBA?

A) A type of variable
B) A set of instructions to automate a task
C) A data structure
D) A loop

Answer: B) A set of instructions to automate a task

Explanation: A macro is a set of instructions that automate a task in VBA. It can be created using the VBA editor in Microsoft Office applications.

4. Which of the following is the correct syntax for a comment in VBA?

A) //
B) —
C) ‘
D) #

Answer: C)

Explanation: A comment in VBA starts with an apostrophe (‘), which tells the VBA compiler to ignore the rest of the line. Comments are used to document code and make it easier to understand.

5. Which of the following is NOT a VBA data type?

A) String
B) Boolean
C) Character
D) Integer

Answer: C) Character

Explanation: There is no data type called Character in VBA. The data types in VBA are String, Integer, Long, Double, Boolean, Date, Object, and Variant.

6. What is the purpose of a variable in VBA?

A) To store data
B) To create a loop
C) To define a function
D) To format cells

Answer: A) To store data

Explanation: A variable in VBA is used to store data that can be used throughout the program. It can be assigned a value, and that value can be changed as the program runs.

7. Which of the following is NOT a VBA loop structure?

A) For Loop
B) While Loop
C) Do While Loop
D) Repeat Until the Loop

Answer: D) Repeat Until the Loop

Explanation: There is no loop structure called Repeat Until Loop in VBA. The loop structures in VBA are For Loop, While Loop, and Do While Loop.

8. What is a function in VBA?

A) A set of instructions to automate a task
B) A data structure
C) A loop
D) A predefined set of code that performs a specific task

Answer: D) A predefined set of code that performs a specific task

Explanation: A function in VBA is a predefined set of code that performs a specific task. It can be called from other parts of the program to perform that task.

9. Which of the following is the correct syntax for a function in VBA?

A) FunctionName()
B) Function Name()
C) Function_Name()
D) functionName

Answer: B) Function Name()

Explanation: The correct syntax for a function in VBA is Function Name(). The function name can be any valid identifier, and it can have parameters in parentheses.

10. Which of the following is the correct syntax for a sub in VBA?

A) Sub Name()
B) Sub_Name()
C) SubName()
D) Sub Name

Answer: A) Sub Name()

Explanation: The correct syntax for a sub in VBA is Sub Name(). The sub name can be any

11. Which of the following is NOT a VBA operator?

A) +
B) *
C) %
D) &

Answer: C) %

Explanation: The % symbol is not a VBA operator. The operators in VBA are +, -, *, /, ^, <, >, <=, >=, =, <>, And, Or, Not, and &.

12. Which of the following is NOT a control structure in VBA?

A) If-Then-Else
B) Select Case
C) For-Next
D) While-Do

Answer: C) For-Next

Explanation: For-Next is a loop structure, not a control structure. The control structures in VBA are If-Then-Else, Select Case, and While-Do.

13. Which of the following is the correct syntax for an If-Then-Else statement in VBA?

A) If condition Then statement Else statement
B) If condition Then statement ElseIf condition Then statement Else statement
C) If condition statement ElseIf condition statement Else statement
D) If condition Then the statement

Answer: B) If condition Then statement ElseIf condition Then statement Else statement

Explanation: The correct syntax for an If-Then-Else statement in VBA is If condition Then statement ElseIf condition Then statement Else statement. The ElseIf and Else parts are optional.

14. What is an array in VBA?

A) A loop structure
B) A data structure that stores a collection of values
C) A control structure
D) A type of variable

Answer: B) A data structure that stores a collection of values

Explanation: An array in VBA is a data structure that stores a collection of values of the same data type. The values are accessed using an index.

15. Which of the following is the correct syntax for declaring an array in VBA?

A) Dim arrName[] As dataType
B) Dim arrName(10) As dataType
C) Dim arrName As dataType(10)
D) Dim arrName As dataType[]

Answer: B) Dim arrName(10) As dataType

Explanation: The correct syntax for declaring an array in VBA is Dim arrName(10) As dataType, where 10 is the size of the array.

16. Which of the following is NOT a VBA keyword?

A) Sub
B) Function
C) Variable
D) Dim

Answer: C) Variable

Explanation: Variable is not a VBA keyword. The keywords in VBA are Sub, Function, Dim, If, Then, Else, ElseIf, End If, Select Case, Case, End Select, For, To, Step, Next, While, Wend, Do, Until, Loop, Exit, Const, and Option Explicit.

17. What is the purpose of Option Explicit in VBA?

A) To force the declaration of all variables
B) To enable debugging mode
C) To define a function
D) To format cells

Answer: A) To force the declaration of all variables

Explanation: Option Explicit is a statement in VBA that forces the declaration of all variables. If a variable is not declared, VBA will generate an error.

18. What is a user-defined function in VBA?

A) A function defined by the user
B) A function defined by Microsoft
C) A function that is predefined in VBA
D) A function that is used for debugging

Answer: A) A function defined by the user

Explanation: A user-defined function in VBA is a function that is defined by the user to perform a specific task. It can be called from other parts of the program.

19. Which of the following is NOT a built-in VBA function?

A) Left
B) Mid
C) Right
D) Set

Answer: D) Set

Explanation: Set is not a built-in VBA function. It is a keyword used to assign an object reference to a variable.

20. What is the purpose of the Left function in VBA?

A) To return a specified number of characters from the left side of a string
B) To return a specified number of characters from the right side of a string
C) To return a specified character from a string
D) To convert a string to lowercase

Answer: A) To return a specified number of characters from the left side of a string

Explanation: The Left function in VBA returns a specified number of characters from the left side of a string. Its syntax is Left(string, length).

21. What is the purpose of the Mid function in VBA?

A) To return a specified number of characters from the left side of a string
B) To return a specified number of characters from the right side of a string
C) To return a specified character from a string
D) To return a specified number of characters from a string starting at a specified position

Answer: D) To return a specified number of characters from a string starting at a specified position

Explanation: The Mid function in VBA returns a specified number of characters from a string starting at a specified position. Its syntax is Mid(string, start, length).

22. What is the purpose of the Right function in VBA?

A) To return a specified number of characters from the left side of a string
B) To return a specified number of characters from the right side of a string
C) To return a specified character from a string
D) To convert a string to lowercase

Answer: B) To return a specified number of characters from the right side of a string

Explanation: The Right function in VBA returns a specified number of characters from the right side of a string. Its syntax is Right(string, length).

23. Which of the following is the correct syntax for a For-Next loop in VBA?

A) For variable = start To end step stepValue
B) For variable = start To end
C) For variable = start Step stepValue To end
D) For variable = start To end stepValue

Answer: D) For variable = start To end stepValue

Explanation: The correct syntax for a For-Next loop in VBA is For variable = start To end stepValue, where stepValue is optional.

24. Which of the following is the correct syntax for a While-Do loop in VBA?

A) While condition Do statement Loop
B) While condition statement Do Loop
C) While statement Do condition Loop
D) While statement Do Loop condition

Answer: A) While condition Do statement Loop

Explanation: The correct syntax for a While-Do loop in VBA is While condition Do statement Loop.

25. What is the purpose of the Do-Until loop in VBA?

A) To repeat a set of statements a specified number of times
B) To repeat a set of statements until a condition is true
C) To repeat a set of statements until a condition is false
D) To perform a task once

Answer: C) To repeat a set of statements until a condition is false

Explanation: The Do-Until loop in VBA repeats a set of statements until a condition is false. Its syntax is Do Until condition Loop.

26. What is the purpose of the Do-While loop in VBA?

A) To repeat a set of statements a specified number of times
B) To repeat a set of statements until a condition is true
C) To repeat a set of statements until a condition is false
D) To perform a task once

Answer: B) To repeat a set of statements until a condition is true

Explanation: The Do-While loop in VBA repeats a set of statements until a condition is true. Its syntax is Do While condition Loop.

27. Which of the following is the correct syntax for a Select Case statement in VBA?

A) Select variable Case condition1 statement1 Case condition2 statement2 End Select
B) Select variable Case condition1 statement1 Case condition2 statement2
C) Select variable Case condition1 statement1 Case condition2 statement2 Default statement3 End Select
D) Select variable Case condition1 statement1 Case condition2 statement2 Default statement3

Answer: C) Select variable Case condition1 statement1 Case condition2 statement2 Default statement3 End Select

Explanation: The correct syntax for a Select Case statement in VBA is Select variable Case condition1 statement1 Case condition2 statement2 Default statement3 End Select.

28. Which of the following is used to define a variable in VBA?

A) Dim
B) Set
C) Private
D) Public

Answer: A) Dim

Explanation: The Dim keyword is used to define a variable in VBA.

29. Which of the following data types can be used to store a decimal number in VBA?

A) Integer
B) Double
C) String
D) Boolean

Answer: B) Double

Explanation: The Double data type can be used to store a decimal number in VBA.

30. Which of the following is the correct syntax to declare a variable as a string in VBA?

A) Dim variable As String
B) Dim variable As Integer
C) Dim variable As Double
D) Dim variable As Boolean

Answer: A) Dim variable As String

Explanation: The correct syntax to declare a variable as a string in VBA is Dim variable As String.

31. Which of the following is the correct syntax to declare a constant in VBA?

A) Const constantName As dataType = value
B) Constant constantName As dataType = value
C) Const constantName = value
D) Constant constantName = value

Answer: A) Const constantName As dataType = value

Explanation: The correct syntax to declare a constant in VBA is Const constantName As dataType = value.

32. What is the purpose of the DoEvents function in VBA?

A) To pause a macro for a specified amount of time
B) To force VBA to update the screen and handle other events in the message queue
C) To close a userform
D) To end a macro

Answer: B) To force VBA to update the screen and handle other events in the message queue

Explanation: The DoEvents function in VBA forces VBA to update the screen and handle other events in the message queue.

33. Which of the following is the correct syntax to open a workbook in VBA?

A) Workbooks.Open “filename”
B) OpenWorkbook “filename”
C) Workbooks.Open filename
D) Open “filename” as workbook

Answer: A) Workbooks.Open “filename”

Explanation: The correct syntax to open a workbook in VBA is Workbooks.Open “filename”.

34. Which of the following is the correct syntax to close a workbook in VBA?

A) Workbook.Close
B) Workbooks.Close
C) ActiveWorkbook.Close
D) ThisWorkbook.Close

Answer: C) ActiveWorkbook.Close

Explanation: The correct syntax to close a workbook in VBA is ActiveWorkbook.Close.

35. Which of the following is the correct syntax to save a workbook in VBA?

A) Workbook.Save
B) Workbooks.Save
C) ActiveWorkbook.Save
D) ThisWorkbook.Save

Answer: C) ActiveWorkbook.Save

Explanation: The correct syntax to save a workbook in VBA is ActiveWorkbook.Save.

36. Which of the following is the correct syntax to save a copy of a workbook in VBA?

A) Workbook.SaveCopyAs “filename”
B) Workbooks.SaveCopyAs “filename”
C) ActiveWorkbook.SaveCopyAs “filename”
D) ThisWorkbook.SaveCopyAs “filename”

Answer: C) ActiveWorkbook.SaveCopyAs “filename”

Explanation: The correct syntax to save a copy of a workbook in VBA is ActiveWorkbook.SaveCopyAs “filename”.

37. Which of the following is the correct syntax to close a userform in VBA?

A) Unload UserForm1
B) Close UserForm1
C) UserForm1.Close
D) Hide UserForm1

Answer: A) Unload UserForm1

Explanation: The correct syntax to close a userform in VBA is Unload UserForm1.

38. Which of the following is the correct syntax to show a userform in VBA?

A) Show UserForm1
B) UserForm1.Show
C) Display UserForm1
D) UserForm1.Display

Answer: B) UserForm1.Show

Explanation: The correct syntax to show a userform in VBA is UserForm1.Show.

39. Which of the following is the correct syntax to refer to a worksheet in VBA?

A) Sheets(“Sheet1”)
B) Worksheet(“Sheet1”)
C) ThisWorkbook.Sheets(“Sheet1”)
D) ThisWorkbook.Worksheet(“Sheet1”)

Answer: A) Sheets(“Sheet1”)

Explanation: The correct syntax to refer to a worksheet in VBA is Sheets(“Sheet1”).

40. Which of the following is the correct syntax to refer to a range of cells in VBA?

A) Range(“A1:B10”)
B) Cells(“A1:B10”)
C) ThisWorkbook.Range(“A1:B10”)
D) ThisWorkbook.Cells(“A1:B10”)

Answer: A) Range(“A1:B10”)

Explanation: The correct syntax to refer to a range of cells in VBA is Range(“A1:B10”).

41. Which of the following is the correct syntax to copy a range of cells in VBA?

A) Range(“A1:B10”).Copy
B) Copy Range(“A1:B10”)
C) ThisWorkbook.Range(“A1:B10”).Copy
D) ThisWorkbook.Copy Range(“A1:B10”)

Answer: A) Range(“A1:B10”).Copy

Explanation: The correct syntax to copy a range of cells in VBA is Range(“A1:B10”).Copy.

42. Which of the following is the correct syntax to paste a range of cells in VBA?

A) Range(“A1:B10”).Paste
B) Paste Range(“A1:B10”)
C) ThisWorkbook.Range(“A1:B10”).Paste
D) ThisWorkbook.Paste Range(“A1:B10”)

Answer: A) Range(“A1:B10”).Paste

Explanation: The correct syntax to paste a range of cells in VBA is Range(“A1:B10”).Paste.

43. Which of the following is the correct syntax to clear the contents of a range of cells in VBA?

A) Range(“A1:B10”).ClearContents
B) Clear Range(“A1:B10”)
C) ThisWorkbook.Range(“A1:B10”).ClearContents
D) ThisWorkbook.ClearContents Range(“A1:B10”)

Answer: A) Range(“A1:B10”).ClearContents

Explanation : The correct syntax to clear the contents of a range of cells in VBA is Range(“A1:B10”).ClearContents.

44. Which of the following is the correct syntax to fill a range of cells with a value in VBA?

A) Range(“A1:B10”).FillValue = “Hello”
B) Fill Range(“A1:B10”) = “Hello”
C) ThisWorkbook.Range(“A1:B10”).FillValue = “Hello”
D) ThisWorkbook.FillValue Range(“A1:B10”) = “Hello”

Answer: A) Range(“A1:B10”).FillValue = “Hello”

Explanation: The correct syntax to fill a range of cells with a value in VBA is Range(“A1:B10”).FillValue = “Hello”.

45. Which of the following is the correct syntax to insert a new row in a worksheet in VBA?

A) Rows(“1:1”).Insert
B) Insert Rows(“1:1”)
C) ThisWorkbook.Rows(“1:1”).Insert
D) ThisWorkbook.Insert Rows(“1:1”)

Answer: A) Rows(“1:1”).Insert

Explanation: The correct syntax to insert a new row in a worksheet in VBA is Rows(“1:1”).Insert.

46. Which of the following is the correct syntax to delete a row in a worksheet in VBA?

A) Rows(“1:1”).Delete
B) Delete Rows(“1:1”)
C) ThisWorkbook.Rows(“1:1”).Delete
D) ThisWorkbook.Delete Rows(“1:1”)

Answer: A) Rows(“1:1”).Delete

Explanation: The correct syntax to delete a row in a worksheet in VBA is Rows(“1:1”).Delete.

47. Which of the following is the correct syntax to insert a new column in a worksheet in VBA?

A) Columns(“A:A”).Insert
B) Insert Columns(“A:A”)
C) ThisWorkbook.Columns(“A:A”).Insert
D) ThisWorkbook.Insert Columns(“A:A”)

Answer: A) Columns(“A:A”).Insert

Explanation: The correct syntax to insert a new column in a worksheet in VBA is Columns(“A:A”).Insert.

48. Which of the following is the correct syntax to delete a column in a worksheet in VBA?

A) Columns(“A:A”).Delete
B) Delete Columns(“A:A”)
C) ThisWorkbook.Columns(“A:A”).Delete
D) ThisWorkbook.Delete Columns(“A:A”)

Answer: A) Columns(“A:A”).Delete

Explanation: The correct syntax to delete a column in a worksheet in VBA is Columns(“A:A”).Delete.

49. Which of the following is the correct syntax to set a value to a cell in VBA?

A) Range(“A1”).Value = “Hello”
B) Set Range(“A1”) = “Hello”
C) ThisWorkbook.Range(“A1”).Value = “Hello”
D) ThisWorkbook.SetValue Range(“A1”), “Hello”

Answer: A) Range(“A1”).Value = “Hello”

Explanation: The correct syntax to set a value to a cell in VBA is Range(“A1”).Value = “Hello”.

50. Which of the following is the correct syntax to get the value of a cell in VBA?

A) Range(“A1”).Value
B) Get Range(“A1”)
C) ThisWorkbook.Range(“A1”).Value
D) ThisWorkbook.GetValue Range(“A1”)

Answer: A) Range(“A1”).Value

Explanation: The correct syntax to get the value of a cell in VBA is Range(“A1”).Value.

51. Which of the following is the correct syntax to get the number of rows in a worksheet in VBA?

A) Rows.Count
B) Columns.Count
C) ThisWorkbook.Rows.Count
D) ThisWorkbook.Columns.Count

Answer: A) Rows.Count

Explanation: The correct syntax to get the number of rows in a worksheet in VBA is Rows.Count.

52. Which of the following is the correct syntax to get the number of columns in a worksheet in VBA?

A) Rows.Count
B) Columns.Count
C) ThisWorkbook.Rows.Count
D) ThisWorkbook.Columns.Count

Answer: B) Columns.Count

Explanation: The correct syntax to get the number of columns in a worksheet in VBA is Columns.Count.

53. Which of the following is the correct syntax to hide a worksheet in VBA?

A) Sheet1.Visible = False
B) Hide Sheet1
C) ThisWorkbook.Sheets(“Sheet1”).Visible = False
D) ThisWorkbook.HideSheet(“Sheet1”)

Answer: A) Sheet1.Visible = False

Explanation: The correct syntax to hide a worksheet in VBA is Sheet1.Visible = False.

54. Which of the following is the correct syntax to unhide a worksheet in VBA?

A) Sheet1.Visible = True
B) Unhide Sheet1
C) ThisWorkbook.Sheets(“Sheet1”).Visible = True
D) ThisWorkbook.UnhideSheet(“Sheet1”)

Answer: A) Sheet1.Visible = True

Explanation: The correct syntax to unhide a worksheet in VBA is Sheet1.Visible = True.

55. Which of the following is the correct syntax to protect a worksheet in VBA?

A) Sheet1.Protect
B) Protect Sheet1
C) ThisWorkbook.Sheets(“Sheet1”).Protect
D) ThisWorkbook.ProtectSheet(“Sheet1”)

Answer: A) Sheet1.Protect

Explanation: The correct syntax to protect a worksheet in VBA is Sheet1.Protect.

56. Which of the following is the correct syntax to unprotect a worksheet in VBA?

A) Sheet1.Unprotect
B) Unprotect Sheet1
C) ThisWorkbook.Sheets(“Sheet1”).Unprotect
D) ThisWorkbook.UnprotectSheet(“Sheet1”)

Answer: A) Sheet1.Unprotect

Explanation: The correct syntax to unprotect a worksheet in VBA is Sheet1.Unprotect.

57. Which of the following is the correct syntax to set the value of a cell based on its row and column numbers in VBA?

A) Cells(1, 1).Value = “Hello”
B) Set Cell(1, 1) = “Hello”
C) ThisWorkbook.Cells(1, 1).Value = “Hello”
D) ThisWorkbook.SetValue Cell(1, 1), “Hello”

Answer: A) Cells(1, 1).Value = “Hello”

Explanation: The correct syntax to set the value of a cell based on its row and column numbers in VBA is Cells(1, 1).Value = “Hello”.

58. Which of the following is the correct syntax to get the value of a cell based on its row and column numbers in VBA?

A) Cells(1, 1).Value
B) Get Cell(1, 1)
C) ThisWorkbook.Cells(1, 1).Value
D) ThisWorkbook.GetValue Cell(1, 1)

Answer: A) Cells(1, 1).Value

Explanation: The correct syntax to get the value of a cell based on its row and column numbers in VBA is Cells(1, 1).Value.

59. Which of the following is the correct syntax to paste a copied range of cells in VBA?

A) Range(“C1”).Paste
B) Paste Range(“C1”)
C) ThisWorkbook.Range(“C1”).Paste
D) ThisWorkbook.PasteRange(“C1”)

Answer: A) Range(“C1”).Paste

Explanation: The correct syntax to paste a copied range of cells in VBA is Range(“C1”).Paste.

60. Which of the following is the correct syntax to clear the contents of a cell in VBA?

A) Range(“A1”).ClearContents
B) Clear Cell(“A1”)
C) ThisWorkbook.Range(“A1”).ClearContents
D) ThisWorkbook.ClearContents(“A1”)

Answer: A) Range(“A1”).ClearContents

Explanation: The correct syntax to clear the contents of a cell in VBA is Range(“A1”).ClearContents.

61. Which of the following is the correct syntax to delete a row in VBA?

A) Rows(1).Delete
B) Delete Row(1)
C) ThisWorkbook.Rows(1).Delete
D) ThisWorkbook.DeleteRow(1)

Answer: A) Rows(1).Delete

Explanation: The correct syntax to delete a row in VBA is Rows(1).Delete.

62. Which of the following is the correct syntax to delete a column in VBA?

A) Columns(1).Delete
B) Delete Column(1)
C) ThisWorkbook.Columns(1).Delete
D) ThisWorkbook.DeleteColumn(1)

Answer: A) Columns(1).Delete

Explanation: The correct syntax to delete a column in VBA is Columns(1).Delete.

63. Which of the following is the correct syntax to insert a row in VBA?

A) Rows(1).Insert
B) Insert Row(1)
C) ThisWorkbook.Rows(1).Insert
D) ThisWorkbook.InsertRow(1)

Answer: A) Rows(1).Insert

Explanation: The correct syntax to insert a row in VBA is Rows(1).Insert.

64. Which of the following is the correct syntax to insert a column in VBA?

A) Columns(1).Insert
B) Insert Column(1)
C) ThisWorkbook.Columns(1).Insert
D) ThisWorkbook.InsertColumn(1)

Answer: A) Columns(1).Insert

Explanation: The correct syntax to insert a column in VBA is Columns(1).Insert.

For in-depth knowledge, continue to follow our website, Freshersnow.com, where you can find VBA quiz questions.

Freshersnow.com is one of the best job sites in India. On this website you can find list of jobs such as IT jobs, government jobs, bank jobs, railway jobs, work from home jobs, part time jobs, online jobs, pharmacist jobs, software jobs etc. Along with employment updates, we also provide online classes for various courses through our android app. Freshersnow.com also offers recruitment board to employers to post their job advertisements for free.