The power of macros is repeating actions for hundreds of rows.
For i = 2 To 11 … Next i | a counter from 2 to 11; Step 2 — the step, Step -1 — backwards (needed when deleting rows) |
For Each c In Range("B2:B11") … Next c | goes through the cells of a range: c is the current cell |
Do While condition … Loop | repeat while the condition is true; Do Until — while it is false |
Exit For, Exit Do | leave the loop early |
How many rows are in the table?
The classic trick: start at the very bottom cell of the column and "jump" up, like Ctrl+↑:
lastRow = Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To lastRow
Cells(i, 3).Value = Cells(i, 2).Value * 1.2
Next i
This way the macro adapts to the length of the table, not just today's 10 rows.
i = 2
Do While Cells(i, 1).Value <> ""
total = total + Cells(i, 2).Value
i = i + 1
Loop
If a loop never ends, Excel "freezes"; stop the macro with Esc or Ctrl+Break. The trainer stops a macro that runs too long by itself.