0
0
Excelspreadsheet~10 mins

Simple VBA procedures in Excel - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to start a VBA procedure named MyMacro.

Excel
Sub [1]()
    ' Your code here
End Sub
Drag options to blanks, or click blank then click option'
AMacro1
BStartMacro
CRunMacro
DMyMacro
Attempts:
3 left
💡 Hint
Common Mistakes
Using spaces in the procedure name
Starting the procedure without Sub
Using reserved words as names
2fill in blank
medium

Complete the code to display a message box with the text "Hello World".

Excel
Sub ShowMessage()
    [1] "Hello World"
End Sub
Drag options to blanks, or click blank then click option'
AShowMsg
BMessageBox
CMsgBox
DDisplay
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect command names like MessageBox
Forgetting to put the message text in quotes
Missing parentheses (optional in VBA but recommended)
3fill in blank
hard

Fix the error in the code to correctly assign the value 10 to cell A1 in the active worksheet.

Excel
Sub SetValue()
    ActiveSheet.Range("A1").[1] = 10
End Sub
Drag options to blanks, or click blank then click option'
AText
BValue
CContent
DSet
Attempts:
3 left
💡 Hint
Common Mistakes
Using Set which is a VBA keyword but not a property
Using Content which is not a valid property
Trying to assign value to Text property
4fill in blank
hard

Fill both blanks to create a procedure that loops from 1 to 5 and shows each number in a message box.

Excel
Sub ShowNumbers()
    Dim i As Integer
    For [1] = 1 To 5
        MsgBox [2]
    Next i
End Sub
Drag options to blanks, or click blank then click option'
Ai
Bj
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names in the loop and message box
Using undeclared variables
Forgetting to declare the variable
5fill in blank
hard

Fill all three blanks to create a procedure that sums numbers from 1 to 10 and shows the result.

Excel
Sub SumNumbers()
    Dim total As Integer
    total = 0
    Dim [1] As Integer
    For [2] = 1 To 10
        total = total + [3]
    Next [2]
    MsgBox total
End Sub
Drag options to blanks, or click blank then click option'
Ai
Dj
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names in declaration and loop
Forgetting to declare the loop variable
Using undeclared variables in the sum