VBA for Excel 2007 tutorial-VBA loop multiplication table


VBA loop: multiplication table

In this example, We use VBA for loop statement to print a multiplication table as shown in the screenshot image below:

To run this example VBA code, you will need a Form and one CommandButton.

VBA for Excel: VBA code example of using VBA for loop to print a multiplication table.
VBA code to print a multiplication table:

  Private Sub CommandButton1_Click()
    Dim i, j As Integer
    For i = 1 To 9
      For j = 2 To 9

        Cells(i, j - 1) = j & "*" & i & "=" & j * i
      Next
   Next

  End Sub



Comments





This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.