To Activities
IT 121 -- Activity A13
Algorithms and Macros
Turn in: An Excel File with your variable
trace and output. Test each macro to make sure you have the correct answer.
Goal: Write basic algorithms and macros.
- Construct the variable trace and predict the output:
Sub Trace1( )
a = 4
If 2 * a - 5 > 3 Then
Else
End If
ActiveCell.Offset(1,
0).Value = a
ActiveCell.Offset(2, 0).Value = b
End Sub
Run Trace1 in Excel to verify your answer.
- Construct the variable trace and predict the output.
Enter 5 in the
active cell before running the Trace2.
Sub Trace2( )
x = ActiveCell.Value
y = ActiveCell.Offset(0, 1)
While x + y
< 100
x = x + 4 * y
y = 3 * y + 1
Wend
ActiveCell.Offset(1, 1)
= x + y
End Sub
Run Trace2 in Excel to verify your answer.