Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare a variable named count as Integer.
Excel
Dim count As [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using String instead of Integer for numbers.
Forgetting to declare the variable type.
✗ Incorrect
In VBA, Integer is used to declare whole number variables like count.
2fill in blank
mediumComplete the code to start a For loop that counts from 1 to 5 using variable i.
Excel
For i = 1 To [1] ' Your code here Next i
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 10 instead of 5 for the loop limit.
Using 0 which would not run the loop as expected.
✗ Incorrect
The loop runs from 1 to 5, so the upper limit is 5.
3fill in blank
hardFix the error in the loop that sums numbers from 1 to 3 into variable total.
Excel
Dim total As Integer total = 0 For j = 1 To 3 total = total [1] j Next j
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using multiplication or division instead of addition.
Using subtraction which would decrease the total.
✗ Incorrect
To sum numbers, you add each number to total using the + operator.
4fill in blank
hardFill both blanks to create a loop that prints numbers from 1 to 4 using variable k.
Excel
For [1] = 1 To [2] Debug.Print k Next k
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different variable name than
k.Setting the upper limit to 5 instead of 4.
✗ Incorrect
The loop variable is k and it counts from 1 to 4.
5fill in blank
hardFill all three blanks to create a loop that stores squares of numbers 1 to 3 in an array arr.
Excel
Dim arr(1 To 3) As Integer Dim n As Integer For [1] = 1 To [2] arr([3]) = n * n Next n
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variables for loop and array index.
Setting the loop limit incorrectly.
✗ Incorrect
The loop variable is n, it runs from 1 to 3, and the array index uses n to store squares.