# How to read Excel rows in a loop

**URL:** <https://forum.electroneek.com/t/how-to-read-excel-rows-in-a-loop/2225>\
**Category:** How to build\
**Tags:** excel\
**Created:** [February 2, 2023, 6:00pm UTC](https://forum.electroneek.com/t/how-to-read-excel-rows-in-a-loop/2225 "2023-02-02T18:00:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mabwa\_Neek](https://forum.electroneek.com/user_avatar/forum.electroneek.com/mabwa_neek/32/403_2.png) [@Mabwa\_Neek](https://forum.electroneek.com/u/Mabwa_Neek)\
**Post date:** [February 2, 2023, 6:00pm UTC](https://forum.electroneek.com/t/how-to-read-excel-rows-in-a-loop/2225/1 "2023-02-02T18:00:44Z")

</div>

To process an Excel file, it is expected that we need to read the row values from a particular column one by one on a loop. For example, imagine you have a column consisting of keywords that you want to input in the browser and extract the search results one by one. We can use the [For each row.](https://help.electroneek.com/hc/en-us/articles/360019151417-For-each-row) activity in Studio

Still, it may be possible that, for some reason, you are required to execute the steps manually in another workflow. So, here is some  
quick step-by-step content to guide you throughout this process.

**Guide**

1. Read the contents of the Excel file using the [Read Excel file](https://help.electroneek.com/hc/en-us/articles/360019275178) activity. The values of the Excel file will be stored in the variable “ **excel\_content** ”
2. Create a variable called “ **counter** ” using the [Assign value to variable](https://help.electroneek.com/hc/en-us/articles/360019151257) activity and assign the “0” value to it
3. Then, use the [If…then](https://help.electroneek.com/hc/en-us/articles/360019445057)activity. Bear in mind that:

- The activities you place below it need to be executed on a loop to read the row data from the variable “ **excel\_content** ” one by one

- The conditions provided should be _**counter \< excel\_content[“Sheet1”].length**_

- The **excel\_content[“Sheet1”].length** returns the highest count of the row from the Excel file

- The values in the variable “ **excel\_content** ” are stored as an array, hence you have to start the loop from “ **counter = 0** ”

1. Next, add the [Console log](https://help.electroneek.com/hc/en-us/articles/360020036337)activity to print the row values one by one.

2. Select the “Calculate a value” parameter for the Message option. The syntax to read row-wise data from the Excel file is excel\_content[Sheet Name][Row Number][Column Name]. Hence, we must use excel\_content[Sheet1][counter][“A”] (keeping in mind that the value of the variable “counter” here is 0).

3. To loop through each row value, it is essential that we iterate the value of the variable “counter” — that is, we must repeatedly input that value. So, in the [Assign value to variable](https://help.electroneek.com/hc/en-us/articles/360019151257-Assign-value-to-variable) activity that comes after the [Console log](https://help.electroneek.com/hc/en-us/articles/360020036337-Console-log) activity, select the “Variable value” as “Calculate a value” and enter the value counter + 1

4. Once done, connect the [Assign value to variable](https://help.electroneek.com/hc/en-us/articles/360019151257-Assign-value-to-variable) activity to the [If…then](https://help.electroneek.com/hc/en-us/articles/360019445057)activity so they form a loop

5. Now, run the workflow — you will see the row values getting printed in the console one by one.  

Let us know your thoughts below

**Happy Automation with ElectroNeek!!!**
