Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub Steps()
- Dim goal, i, allSteps As Integer
- goal = 10000
- i = 1
- Dim commandInput As String
- commandInput = Range("A" & i)
- Do While commandInput <> "Going home"
- Dim currentSteps As Integer
- currentSteps = Range("A" & i)
- allSteps = allSteps + currentSteps
- i = i + 1
- If allSteps >= goal Then
- Exit Do
- End If
- commandInput = Range("A" & i)
- Loop
- If commandInput = "Going home" Then
- allSteps = allSteps + Range("A" & i + 1)
- End If
- If allSteps >= goal Then
- Debug.Print "Goal reached! Good job!"
- Else
- Debug.Print goal - allSteps & " more steps to reach goal."
- End If
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement