Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Loop to display numbers in VBA
#1
Description:

This code uses a loop to display numbers from 1 to 5 in separate message boxes.

Example:

Sub DisplayNumbers()
    Dim i As Integer

    For i = 1 To 5
        MsgBox "Number: " & i
    Next i
End Sub

Explanation:

This code defines a subroutine named DisplayNumbers. 
It declares a variable i to use as a loop counter. 
The For loop runs from 1 to 5, and for each iteration, a message box displays the value of i.

The For loop is a control structure used to execute a block of code repeatedly for a specific range of values. 
In this case, the loop runs five times, and the i variable takes values from 1 to 5.
Also follow me on Youtube for videos about video games:
https://www.youtube.com/channel/UCxfkGVU...2mQ/videos
Reply


Messages In This Thread
Loop to display numbers in VBA - by Qomplainerz - 07-27-2023, 07:33 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Autofill a series of numbers in a column Qomplainerz 0 390 07-27-2023, 11:23 AM
Last Post: Qomplainerz
  Loop through columns and clear contents Qomplainerz 0 397 07-27-2023, 11:21 AM
Last Post: Qomplainerz
  Generate random numbers in VBA Qomplainerz 0 417 07-27-2023, 11:03 AM
Last Post: Qomplainerz
  Loop through worksheets and print their names in the immediate window Qomplainerz 0 410 07-27-2023, 09:42 AM
Last Post: Qomplainerz
  Loop to fill numbers in cells with VBA Qomplainerz 0 380 07-27-2023, 08:16 AM
Last Post: Qomplainerz
  Calculate the average of three numbers in VBA Qomplainerz 0 327 07-27-2023, 07:40 AM
Last Post: Qomplainerz
  Do Until loop in VBA Qomplainerz 0 284 07-26-2023, 08:34 PM
Last Post: Qomplainerz
  Do While loop in VBA Qomplainerz 0 305 07-26-2023, 08:33 PM
Last Post: Qomplainerz
  For...Next loop in VBA Qomplainerz 0 324 07-26-2023, 08:32 PM
Last Post: Qomplainerz
  Floating-point numbers with double precision in VBA Qomplainerz 0 302 07-26-2023, 08:23 PM
Last Post: Qomplainerz

Forum Jump:


Users browsing this thread: 2 Guest(s)