How to loop without VBA or macros?

In this Excel VBA tutorial lesson, you will learn how to create a loop formula in Excel without using macro or VBA.

It is very common to create the required loops in Excel vba like if loop, do while loop, do until loop, for loop, while wend loop for different purposes.

But here we will create a similar effect in Excel using formulas.

Excel loop formula

In any Excel file name the sheet as "testsheet" and "result sheet" and in cell A1 of "result sheet" white formula:

=IF('testsheet'!C1 <= 99,'testsheet'!A1,"")

Copy this until row 40.

excel loop copy formula

Now in cell B1 write formula: =A1

write formula loop

Now in cell B2 write: =B1 & A2

write formula column b

Looping in Excel without Vba code

Copy this till B40. We will get the following results:

loop wothout vba code

It worked the same as for loop in but without Vba code involved.

Excel loop IF INDEX formula

In Excel, you can perform simple loops without using VBA or macros also by using the "IF" function and the "INDEX" function in combination with a named range. Here's how:

  1. Prepare your list: First, create a list of the values you want to loop through. This list should be in a single column, with each item in a separate cell.
  2. Create a named range: Select the list of values and give it a descriptive name, such as "Values." This will make it easier to reference the list in your formulas.
  3. Enter the INDEX function: In the first cell where you want to display the first value in your list, enter the formula "=INDEX(Values,1)," replacing "Values" with the name you gave to your list of values.
  4. Enter the IF function: In the next cell, enter the formula "=IF(INDEX(Values,ROW()-1)<>INDEX(Values,ROWS(Values)),INDEX(Values,ROW()),"")." This formula uses the "INDEX" function to retrieve the current value from your list, and the "IF" function to check if the current value is different from the previous value. If the current value is different, it is displayed in the cell. If it is the same, the cell is left blank.
  5. Copy the formula: Copy the formula down the column, so that each cell in the column displays the next value in your list.
  6. Finalize the loop: Once you've finished entering the formulas, you should have a column that displays the values from your list, one after the other. You can now use these values in your Excel worksheet as needed.

These steps should help you perform simple loops in Excel without using VBA or macros. Keep in mind that this technique is limited and may not be suitable for more complex looping needs. In those cases, you may need to use VBA or a macro.