Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 05.
- Sub PrintNumbersEndingIn7()
- Dim n As Integer
- Dim i As Integer
- Dim result As String
- ' Get the end of the range from cell A1
- n = Range("A1").Value
- ' Loop through numbers from 7 to n
- For i = 7 To n
- ' Check if the number ends in 7
- If i Mod 10 = 7 Then
- result = result & i & " "
- End If
- Next i
- ' Print the result in cell A2
- Range("A2").Value = Trim(result)
- End Sub
- 06.
- Sub PrintNumbersOver3()
- Dim n As Integer
- Dim i As Integer
- Dim result As String
- ' Get the end of the range from cell A1
- n = Range("A1").Value
- ' Loop through numbers from 1 to n
- For i = 1 To n
- ' Check if the number is divisible by 3
- If i Mod 3 = 0 Then
- result = result & i & " "
- End If
- Next i
- ' Print the result in cell A2
- Range("A2").Value = Trim(result)
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement