This is a strictly technical post on the use of Workfusion RPA Express to check the last worksheet in Microsoft Excel. This scenario is often used if there are multiple tabs of Excel Worksheet, and you would like the bot to scroll through each Worksheet until the last Worksheet and stop automatically.
To begin, you will need to declare two variables of String type below:
I just initialized them to be the same name as the variables. These two variables will be a checker to verify is it the last Worksheet.
A few shortcut keys that you will have to utilize for this operation are:
– Select Worksheet name – Alt, H, O, R
– Switch Worksheet – Ctl+PgUp or Ctl+PgDown
Let’s take a look at the scenario below where we have multiple worksheets in a Microsoft Excel file.
The algorithm is as below:
While (currsheet is not equal to nextsheet) //It maybe do not contain depending on version
Step 1: Select current worksheet name based on shortcut keys above
Step 2: Copy and Save the clipboard into variable – currsheet
Step 3: <Perform the necessary operations for this sheet>
Step 4: Change the Worksheet based on the shortcut keys above
Step 5: Select current worksheet name based on shortcut keys above
Step 6: Copy and Save the clipboard into variable – nextsheet
— And this will loop through the various sheets until it has reached the end of the worksheet
Here is the full script.
You will notice once it has reached the last worksheet, doing a Ctl-PgDown will still bring it to the same worksheet. It will not move down any further. Step 5 and Step 6 will be the same as Step 1 and Step 2. The while loop will naturally terminate and the bot will stop its operations.
Here is the video in action.
This is a strictly keyboard-only operation, so it is highly portable and you can share the scripts with colleagues easily.