Excel VBA: A Step-By-Step Guide To Learn And Master Excel VBA Programming by Hein Smith

Excel VBA: A Step-By-Step Guide To Learn And Master Excel VBA Programming by Hein Smith

Author:Hein Smith [Smith, Hein]
Language: eng
Format: epub
Published: 2018-06-28T23:00:00+00:00


However, if you wrote this code, it would give you an error message because VBA requires a variable to start the Programming Loop.

7- After we have defined the parameters of the Loop function, we want to introduce the mathematical function that the program will execute. Do this by using the third variable “Answer”. Write a new line of code that says “Answer=Answer+StartValue”

8- Now we want a dialogue box to appear after the program??? runs every step of the program???. Write a new line of code that reads “MsgBox Answer”

9- Next, we will tell the program to repeat the Loop. Write “Next” followed by the start value variable.

10-After the program has run through the set number of loops, we want another dialogue box to appear that says “You Did It!” Code this dialogue box.

11-Together your code might look something like this:

Sub LoopPractice()

Dim StartValue As Integer

Dim EndValue As Integer

Dim Answer As Integer

EndNumber=10

For StartNumber=1 To EndNumber

Answer=Answer+StartNumber

MsgBoxAnswer

Next StartNumber

MsgBox “You Did It!”

End Sub

12-Run the program. 10 dialogue boxes should appear that contain the answers to the summed numbers up to that point in the program. After the 10th box, a final dialogue box will appear that says “You Did It!”



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.