Create sheet name dyamically by iteartion

Hi All,
Im using do while loop for data scraping while iterating im using append range to write in sheet i want the 1 page data scraping result in sheet1 and 2nd page result in sheet2 and so on by dynmically

@pravin_calvin …if you have counter variable set up and then you can use that like below

“Sheet” + (counterVariable).tostring

1 Like

Hi @pravin_calvin sorry for late response

I will explain the process how to do that

First for demonstration i am using ACME website worklist table for datatscrapping. I am iterating through each pages and putting the each page as in each sheet of workbook (page1 in Sheet1, page2 in Sheet2 like so on …)

1.First i assigned the count variable with value of 1 ( to add the sheet names)


  1. Use while loop with condition as True.


inside the while loop do the following
a. Use Assign activity to intiliase the datatable where scrapped page data is stored

in our case , ExtractDataTable = New System.Data.DataTable

   b. Use datatscrapping to extarct the page and store in ExtractDataTable variable.

   c. Use write range to write the datatable into the excel file with sheet name as "Sheet"+count.ToString.


   d.  if the webpage where datatascrpaiing is done is having some forward button where u can move by each and each pages, use this as for element exists and store in boolean variable let's say next_page

next button in this webpage.

We can use this element for checking whether the there is next page or not. so for that we use element exist activity to check that.

(This next button will disppears when comes to last page)

e. Next use an if condition if condition next_page, if the condition is true then in then section , we can use click activity for clicking the forward button and also to increment the count variable by one.

if condition becomes false then it indicates that it is last so scrapping is over so we can break activity to exit out of loop,

Finally what i get as output of this process is

Each page data is in each sheet , page1 in sheet1, page2 in sheet2 and so on…

Hope this explaination helps you


Nived N

Happy Automation

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.