- Release Notes
- Getting Started
- Tutorials
- Automation Projects
- Creating Automations
- Automation Basics
- Object Repository
- Automation Best Practices
- Tutorial: Creating a Pivot Table
- Tutorial: Iterating Through Rows in a Table
- Tutorial: Comparing Excel Files and Emailing Reconciliation Errors
- Tutorial: Extracting Data From Automated Emails and Moving It to a Desktop Application
- Tutorial: Filtering Data in Excel
- Tutorial: Formatting Cells
- Tutorial: Adding Information About the Files in a Folder to an Excel File
- Tutorial: Adding Your Own Formulas to the Project Notebook
- PowerPoint Automation
- Data Automation
- Common Activities
- Google Workspace Automation
- OneDrive & SharePoint Automation
- Troubleshooting
StudioX User Guide
Tutorial: Comparing Excel Files and Emailing Reconciliation Errors
In this tutorial, we will create an automation to compare the amounts in a spreadsheet that contains invoices with the amounts from a CSV file that contains a summary per supplier. If any reconciliation errors exist between the files, we will create a CSV file with details and send the file by email.
We will create a project with the following activities:
- Two Use Excel File activities to indicate the Excel file with the invoices and the file where we want to reconcile the data.
- A series of Write Cell activities to add two column headers to the reconciliation Excel file and to calculate the sum of invoices for one supplier and the difference between that sum and the amount in the initial summary. We will add a Copy Range activity to copy the formulas we added for one supplier to all the rows in the sheet so that we can perform the same calculations for all the suppliers, and then add one more Write Cell activity to add the total difference to a cell.
- An If activity where we will add a condition that if there are reconciliation errors (the sum of differences is greater than 0), a CSV file with details should be created and emailed to a specified address. For the email tasks, inside the If activity we will add a Use Desktop Outlook App activity to indicate the Outlook account we want to send the mail from and a Send Email activity inside Use Desktop Outlook App.
-
Set up the project and get the necessary files.
- Create a new blank project using the default settings.
- Download and extract the archive with the automation project in this tutorial using the button at the bottom of this page. Copy the folder data to your project folder.
-
Add the Excel files to the project.
- Click Add Activity in the Designer panel, and then find the Use Excel File activity in the search box at the top of the screen and select it. A Use Excel File activity is added to the Designer panel.
-
In the activity:
- Click
Browse
next to the Excel
file field, and then browse to and select the file
invoices.xlsx
-
In the field Reference as, enter
Invoices
.You have indicated that you will work on the file invoices.xlsx that is known in your automation as Invoices.
- Click
Browse
next to the Excel
file field, and then browse to and select the file
- Click Add Activity inside the Use Excel File activity, and then add a another Use Excel File activity.
-
In the second activity:
- Click
Browse
next to the Excel
file field, and then browse to and select the file
reconcile.xlsx
-
In the field Reference as, enter
Rec
.You have indicated that you will work on the file reconcile.xlsx that is known in your automation as Rec.
- Click
Browse
next to the Excel
file field, and then browse to and select the file
-
Copy the data to the reconciliation file.
- Click Add Activity inside the second Use Excel File, and then find the Read CSV activity in the search box at the top of the screen and select it. The activity is added inside the Use Excel File activity.
-
In the Read CSV activity:
- Click Browse
next to the Read
from file field, and then browse to and select the file
summary.csv
. -
Click Plus on the right side of the Output to field, and then select Rec > Summary [Sheet]. The field is updated with your selection [Rec] Summary.
You have indicated that you want to copy the data from the CSV file summary.csv to the file Rec in the sheet Summary.
- Click Browse
next to the Read
from file field, and then browse to and select the file
- Click Add Activity inside the second Use Excel File below the Read CSV activity, and then find the Copy Range activity in the search box at the top of the screen and select it. A Copy Range activity is added inside the Use Excel File activity.
-
In the Copy Range activity:
-
Click Plus on the right side of the Source field, and then select Invoices > Invoices [Sheet]. Your selection is displayed in the field as [Invoices] Invoices.
You have indicated that you want to copy the Invoices sheet from the file Invoices.
-
Click Plus on the right side of the Destination field, and then select Rec > Invoices [Sheet]. Your selection is displayed in the field as [Rec] Invoices.
You have indicated that you want to paste the copied range to the Invoices sheet in the file Rec.
-
-
Make the necessary calculations to compare the data.
- In the Activities panel, select the Excel tab, and then drag the Write Cell activity and drop it in the second Use Excel File below Copy Range. A Write Cell activity is added to the Designer panel.
-
In the Write Cell activity:
- Click Plus
on the right side of
the What to write field, and then select Text. In
the Text Builder, enter the text
Calculated Amount
. -
Click Plus on the right side of the Where to write field, and then select Rec > Indicate in Excel. The spreadsheet is opened in Excel. Select the cell C1, and then click Confirm. The field is updated with your selection [Rec] Summary!C1.
You have indicated that you want the first cell in column C from the Summary sheet of the Rec file to contain the textCalculated Amount
.
- Click Plus
on the right side of
the What to write field, and then select Text. In
the Text Builder, enter the text
-
Add a second Write cell activity below the previous one and, in the
activity::
- Click Plus
on the right side of
the What to write field, and then select Text. In
the Text Builder, enter the text
=IF(A2 <> "", SUMIF(Invoices!B:B, A2, Invoices!C:C), "")
. -
Click Plus on the right side of the Where to write field, and then select Rec > Indicate in Excel. The spreadsheet is opened in Excel. Select the cell C2, and then click Confirm. The field is updated with your selection [Rec] Summary!C2.
You have indicated that you want C2 from the Summary sheet of the Rec file to contain the formula=IF(A2 <> "", SUMIF(Invoices!B:B, A2, Invoices!C:C), "")
. This formula checks if the supplier cell (A2) is not empty and sums the values in the C column of the Invoices sheet for the supplier in the cell A2 of the Summary sheet.
- Click Plus
on the right side of
the What to write field, and then select Text. In
the Text Builder, enter the text
-
Add a third Write cell activity below the previous one and, in the
activity::
- Click Plus
on the right side of
the What to write field, and then select Text. In
the Text Builder, enter the text
Difference
. -
Click Plus on the right side of the Where to write field, and then select Rec > Indicate in Excel. The spreadsheet is opened in Excel. Select the cell D1, and then click Confirm. The field is updated with your selection [Rec] Summary!D1.
You have indicated that you want the first cell in column D from the Summary sheet of the Rec file to contain the textDifference
.
- Click Plus
on the right side of
the What to write field, and then select Text. In
the Text Builder, enter the text
-
Add a fourth Write cell activity below the previous one and, in the
activity::
- Click Plus
on the right side of
the What to write field, and then select Text. In
the Text Builder, enter the text
=IF(A2 <> "", C2-B2, "")
. -
Click Plus on the right side of the Where to write field, and then select Rec > Indicate in Excel. The spreadsheet is opened in Excel. Select the cell D2, and then click Confirm. The field is updated with your selection [Rec] Summary!D2.
You have indicated that you want D2 from the Summary sheet of the Rec file to contain the formula=IF(A2 <> "", C2-B2, "")
. This formula checks if the supplier cell (A2) is not empty and calculates the difference between the values in cells C2 and B2 of the Summary sheet.
- Click Plus
on the right side of
the What to write field, and then select Text. In
the Text Builder, enter the text
- Click Add Activity below the last Write Cell activity, and then find the Copy Range activity in the search box at the top of the screen and select it. A Copy Range activity is added to the Designer panel.
-
In the Copy Range activity:
- Click Plus on the right side of the Source field, and then select Rec > Indicate in Excel. The spreadsheet is opened in Excel. Select the range C2:D2, and then click Confirm. The field is updated with your selection [Rec] Summary!C2:D2.
- Click Plus on the right side of the Destination field, and then select Rec > Indicate in Excel. The spreadsheet is opened in Excel. Select the range C3-D20, and then click Confirm. The field is updated with your selection [Rec] Summary!C3-D20.
-
From the What to copy drop-down menu, select Formulas
You have indicated that you want to paste the formula in the copied range C2:D2 down to the same columns in the sheet.
- In the Activities panel, select the Excel tab, and then drag the Write Cell activity and drop it below the last Copy Range activity. A Write Cell activity is added to the Designer panel.
-
In the Write Cell activity:
- Click Plus
on the right side of
the What to write field, and then select Text. In
the Text Builder, enter the formula
=SUM(Summary!D:D)
. -
Click Plus on the right side of the Where to write field, and then select Rec > Indicate in Excel. The spreadsheet is opened in Excel. Select the sheet Invoices, then the cell F1, and then click Confirm. The field is updated with your selection [Rec] Invoices!F1.
You have indicated that you want the first cell in column F from the Invoices sheet of the Rec file to contain the formula=SUM(Summary!D:D)
. The formula adds the sum of the differences in the D column of the Summary sheet to the F1 cell in the Invoices sheet.
- Click Plus
on the right side of
the What to write field, and then select Text. In
the Text Builder, enter the formula
-
Send an email with details about the reconciliation if the sum of differences
is greater than 0.
- Click Add Activity below the last Write Cell activity, and then, in the search box at the top of the screen, locate and select If. An If activity is added to the Designer panel.
- In the If activity, select Open in Advanced Editor next to the Condition field to open the Condition Builder.
-
In the Condition Builder, add the condition "if the sum of differences
is greater than 0":
- Click Plus on the right side of the field on the left, and then select Rec > Indicate in Excel. The spreadsheet is opened in Excel. Select the sheet Invoices, then the cell F1, and then click Confirm. The field is updated with your selection [Rec] Invoices!F1.
- From the drop-down menu in the middle, select greater than.
-
Click Plus on the right side of the field on the right, select Number, enter 0 and click Save twice.
The activities you add in the Then branch of the If activity will be executed if this condition is met.
- In the Activities panel, select the CSV tab, and then drag the Write CSV activity and drop it in the Then branch of the If activity. A Write CSV activity is added to the Designer panel.
-
In the Write CSV activity:
- Click Plus
on the right side of
the Write to what file field, and then select
Text. In the Text Builder, enter
reconcile-
, and then from the Plus menu on the right side of the Text Builder select Notebook > Date [Sheet] > YYYYMMDD [Cell]. The text in the Text Builder is updated toreconcile-[Notes] Date!YYYYMMDD
. Enter the text.csv
at the end and click Save. The final text should bereconcile-[Notes] Date!YYYYMMDD.csv
. -
Click Plus on the right side of the Write from field, and then select Rec > Summary [Sheet]. The field is updated with your selection [Rec] Summary.
You have indicated that you want to create a CSV file in the project folder whose name contains the word reconcile and today's date and copy the Summary sheet of the Rec file to it.
- Click Plus
on the right side of
the Write to what file field, and then select
Text. In the Text Builder, enter
- In the Activities panel, select the Mail tab, and then drag the Use Desktop Outlook App activity and drop it in the Then branch of the If activity below the Write CSV activity.
-
In the activity, the default email account is already selected in the
Account field. If you want to use a different account, select
it from the drop-down menu.
In the Reference as field, leave the default value
Outlook
as the name by which to refer to the account in the automation. - In the Activities panel, drag the Send Email activity and drop it inside the Use Desktop Outlook App activity.
-
In the Send Email activity:
- Click Plus on the right side of the Account field, and then select Outlook.
- Click Plus on the right side of the To field, and then select Text. In the Text Builder window, enter an email address where to send the email. For example, you can enter your own email address to send the email to yourself. If you leave the Save as draft option selected, the automation does not send the email, it instead saves the email to the Outlook Drafts folder.
- Click Plus
on the right side of
the Subject field, and then select Text. In the
Text Builder window, enter
Reconciliation errors for
, and then from the Plus menu on the right side of the Text Builder select Notebook > Date [Sheet] > Today [Cell]. The text in the Text Builder is updated toReconciliation errors for [Notes] Date!Today
. - Click Plus
on the right side of
the Body field, and then select Text. In the Text
Builder window, enter text for the body of the email, for
example
One or more suppliers have reconciliation errors. See attached CSV file for details.
. -
For Attachments, select Files, and then enter the same file name as the one used in the Write CSV activity in step 5,
reconcile-[Notes] Date!YYYYMMDD.csv
. For example, you can open the Text Builder for the Write to what file field of the Write CSV activity, copy all the text, and then paste in the Text Builder for the file attachment field.
- Click Save in the StudioX ribbon to save the automation, then click Run to execute the automation.
The invoices and summary data are copied to the reconcile.xlsx file, the calculations are performed and, because the total amount in the invoices does not match the one in the summary for one of the suppliers, the Summary sheet of the reconcile.xsls file is copied to a CSV file whose name includes today's date, the file is attached to an email and sent to the specified address. In the file, you can identify the supplier with reconciliation errors by the value in cell D3 that is greater than 0.