Advertisement
desislava_topuzakova

Untitled

Sep 1st, 2024
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. 05.
  2. Sub PrintNumbersEndingIn7()
  3. Dim n As Integer
  4. Dim i As Integer
  5. Dim result As String
  6.  
  7. ' Get the end of the range from cell A1
  8. n = Range("A1").Value
  9.  
  10. ' Loop through numbers from 7 to n
  11. For i = 7 To n
  12. ' Check if the number ends in 7
  13. If i Mod 10 = 7 Then
  14. result = result & i & " "
  15. End If
  16. Next i
  17.  
  18. ' Print the result in cell A2
  19. Range("A2").Value = Trim(result)
  20. End Sub
  21.  
  22. 06.
  23. Sub PrintNumbersOver3()
  24. Dim n As Integer
  25. Dim i As Integer
  26. Dim result As String
  27.  
  28. ' Get the end of the range from cell A1
  29. n = Range("A1").Value
  30.  
  31. ' Loop through numbers from 1 to n
  32. For i = 1 To n
  33. ' Check if the number is divisible by 3
  34. If i Mod 3 = 0 Then
  35. result = result & i & " "
  36. End If
  37. Next i
  38.  
  39. ' Print the result in cell A2
  40. Range("A2").Value = Trim(result)
  41. End Sub
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement