Skip to main content

Loop through Excel worksheet rows

Sophie avatar
Written by Sophie
Updated over a week ago

Definition and Usage

This command iterates through each row of a specified Excel worksheet, allowing you to process data row by row. It provides a structured way to loop through worksheet data between specified start and end rows, making it ideal for data processing, validation, or extraction operations.


Parameter Values

Input parameters

Parameter

Description

Possible Values

Required

Options / Notes

Excel instance

Please select an Excel instance to identify the instance to operate on

Excel instance variable

Yes

Must be created via the "Launch Excel" or "Get active Excel worksheet" command

Worksheet name

Specify the worksheet name

Text

No

Leave blank to use the active worksheet

Start row

Specify the starting row number for the loop

Integer

Yes

Typically starts at 1 or 2 (if there's a header row)

End row

Specify the ending row number for the loop

Integer

Yes

Use -1 to iterate until the last row with data

Advanced settings

Parameter

Description

Possible Values

Required

Options / Notes

Read values as displayed

Read the value shown in Excel instead of the raw format

True/False

No

When checked, reads formatted values as they appear in Excel; when unchecked, reads raw values

Variables produced

This action produces a variable that stores the current Excel row being processed during each iteration. The variable contains all cell values from the current row, allowing you to access individual cell data.


Using Variables in Conditions

You can use the {variableName} syntax to reference previously created variables in parameter fields. For example, you might use a counter variable to determine the start or end row dynamically. When working with the output row variable, you can access individual cell values using array notation or methods provided by the Excel object model.


Notes

  • Before using this command, ensure that a valid Excel instance has been created and the target file is open.

  • The loop will process each row sequentially from the start row to the end row.

  • When using -1 as the end row value, the loop will continue until it reaches the last row containing data.

  • The produced variable contains the entire row data, which can be accessed in subsequent actions within the loop.

  • For optimal performance, specify a finite end row rather than using -1 when working with large datasets.

Did this answer your question?