VBA Excel increment and decrement - learnit

Home Top Ad

Post Top Ad

Wednesday, July 21, 2021

VBA Excel increment and decrement

VBA Excel increment and decrement | VBA Excel

What is Excel VBA?

VBA stands for Visual Basic for Applications. Excel VBA is Microsoft’s programming language for Excel and all the other Microsoft Office programs, like Word and PowerPoint. The Office suite programs all share a common programming language.


FOR Excel VBA

Loop: Looping is one of the most powerful programming techniques. A loop in Excel VBA enables you to loop through a range of cells with just a few codes lines.


Increment

We are actually creating a loop that uses a variable counter as the loop's "time keeper." At the start of the loop, we set it to the value start counter and then increment it by one during each loop until it reaches the end condition. The loop will continue until the value of the counter equals end counter. When both of the above values are met, the loop executes for the final time.


Why Use Excel VBA?

While users cannot directly manipulate the main Excel software through VBA, they can, however, master the art of making macros to optimize their time in Excel. There are two ways to make Excel macros.


The first method is to use the Macro Recorder. After activating the recorder, Excel will record all the steps a user makes and save it as a “process” known as a macro. When the user ends the recorder, this macro is saved and can be assigned to a button that will run the exact same process again when clicked. This method is relatively simple and requires no inherent knowledge of the VBA code. This method will work for simple processes.

Example Increment

Sub forLoop_Increment ()
Dim i as integer
for i=1 to 15 step 1
Cells(i,1).Value=1
Next
End Sub


Sub forLoop_decrement
Dim i as integer
for i=15 to 1 step -1
Cells(i,1).Value=1
Next
End sub

Please Watching My Video is Below

No comments:

Post a Comment

Post Top Ad