For Each Next Loop

The For...Next loop will be described in more detail in Chapter 7. It is introduced in this section in order for us to tackle important examples. The purpose of using the For. Next statements is to create a 'loop'. A loop is a construct that is repeated several times. This could be, for example, each worksheet in a workbook or each cell in a range, and so on.

The syntax of the For Each ... Next loop is:

For Each element In group statements Next

For example:

For Each cell In Range ("Week_sales")

Statements Next

Notice how the statements between For Each cell in Range ("week_sales") and Next are indented.

0 0

Post a comment