Basic VBA programming  Excel MCQs

  1. Which VBA keyword is used to declare a variable?
    a) DIM
    b) VAR
    c) LET
    d) DECLARE
    Answer: a) DIM
  2. What does the VBA Sub keyword define?
    a) A function
    b) A procedure
    c) A variable
    d) A loop
    Answer: b) A procedure
  3. Which VBA function is used to display a message box?
    a) MsgBox
    b) AlertBox
    c) ShowMessage
    d) DisplayBox
    Answer: a) MsgBox
  4. How do you end a VBA subroutine?
    a) END
    b) EXIT
    c) END SUB
    d) STOP
    Answer: c) END SUB
  5. In VBA, what does the Range("A1").Value refer to?
    a) The cell format of cell A1
    b) The address of cell A1
    c) The value stored in cell A1
    d) The formula in cell A1
    Answer: c) The value stored in cell A1
  6. Which VBA statement is used to loop through a range of cells?
    a) FOR EACH
    b) WHILE
    c) DO UNTIL
    d) REPEAT
    Answer: a) FOR EACH
  7. What does the Cells(1, 1).Value notation represent in VBA?
    a) The value of cell A1
    b) The value of cell B1
    c) The value of cell A2
    d) The value of cell B2
    Answer: a) The value of cell A1
  8. Which VBA function is used to get user input in a dialog box?
    a) InputBox
    b) GetUserInput
    c) Prompt
    d) UserResponse
    Answer: a) InputBox
  9. How do you create a loop that runs from 1 to 10 in VBA?
    a) FOR i = 1 TO 10
    b) LOOP 1 TO 10
    c) REPEAT 1 TO 10
    d) WHILE i < 10
    Answer: a) FOR i = 1 TO 10
  10. Which VBA keyword is used to handle errors?
    a) HANDLE
    b) ERROR
    c) ON ERROR
    d) TRY
    Answer: c) ON ERROR
All Copyrights Reserved 2025 Reserved by T4Tutorials