Use the row and column operations in the Apple Numbers
package to build an automation that cleans up a monthly expense report by
removing disclaimer rows, deleting empty columns, clearing blank rows, and inserting a
summary total row.
About this task
Every month, a finance team receives a raw expense report exported from their
accounting system into an Apple Numbers spreadsheet. The exported file
contains formatting issues that require manual cleanup before the data is ready for
review: disclaimer rows at the top, empty columns generated by the export, blank rows
scattered throughout the data, and no summary row at the bottom.
In this example, you build an automation that uses the row and column actions in the Apple Numberspackage to
handle the entire cleanup process in a single run. The automation performs the
following operations:
- Opens the expense report file.
- Deletes the disclaimer rows at the top of the spreadsheet.
- Removes empty columns generated by the export.
- Removes blank rows scattered between data rows.
- Counts the remaining data rows.
- Inserts a summary row and adds a total formula.
- Saves and closes the file.
The following table shows the sample data before and after the cleanup:
Table 1. Expense report before cleanup
| A |
B |
C |
D |
E |
F |
G |
| DISCLAIMER: This report is
auto-generated and subject to review. |
| Export date: 2026-05-01 |
| Date |
Department |
(empty) |
Category |
Amount |
(empty) |
Approved by |
| 2026-04-02 |
Marketing |
|
Travel |
450.00 |
|
J. Smith |
| (blank row) |
| 2026-04-05 |
Engineering |
|
Software |
1200.00 |
|
R. Patel |
Table 2. Expense report after cleanup
| Date |
Department |
Category |
Amount |
Approved by |
| 2026-04-02 |
Marketing |
Travel |
450.00 |
J. Smith |
| 2026-04-05 |
Engineering |
Software |
1200.00 |
R. Patel |
| ... |
... |
... |
... |
... |
|
|
TOTAL |
12350.00 |
|
Before you begin
Verify the following before you begin:
- You have Automation 360 with access to the Apple Numbers
package .
- A macOS device is registered as a Bot Runner in Control Room.
- A sample expense report file is saved on your desktop in
.numbers format. The file contains:
- Two disclaimer rows at the top (rows 1 and 2) that are not part of
the data.
- Column headers in row 3: Date, Department, (empty column), Category,
Amount, (empty column), Approved by.
- Several blank rows scattered between data rows.
- 15 to 20 rows of sample expense entries.
Procedure
-
Open the expense report file.
-
In the Actions panel, navigate to
.
-
Double-click or drag the Open action to add it
to the automation.
-
In the File path field, enter the path to the
expense report file on your desktop.
For example,
/Users/yourname/Desktop/expense-report-apr-2026.numbers.
-
In the Create session field, select
Local session and enter a name for the
session that the action creates for the open file.
For example, ExpenseCleanup.
A session name is a label that identifies the open file. You use this
same session name in all subsequent actions so that
the automation knows which file to work with.
-
Delete the disclaimer rows at the top of the spreadsheet.
Rows 1 and 2 contain export disclaimers that are not part of the expense
data. After you delete these rows, the column headers move up to row 1.
-
In the Actions panel, navigate to .
-
Double-click or drag the Delete rows/columns
action to add it to the automation.
-
In the Session name field, enter
ExpenseCleanup.
-
Select Rows as the delete option, then select
Specific row.
-
In the Table name field, enter
Table 1.
-
In the Row number field, enter the row or row
range to delete.
For example, enter 1:2 to delete rows 1
through 2 in a single action.
The two disclaimer rows are removed. The column headers (Date,
Department, Category, Amount, Approved by) are now in row 1.
-
Verify the total number of columns in the spreadsheet.
Checking the column count before you delete columns is a good practice. It
confirms that the file structure matches what the automation expects.
-
In the Actions panel, navigate to .
-
Double-click or drag the Get number of columns
action to add it to the automation.
-
In the Session name field, enter
ExpenseCleanup.
-
In the Sheet name field, enter the name of the
sheet that contains the table.
For example, Sheet 1.
-
In the Table name field, enter the name of the
table in your Numbers spreadsheet.
By default, Apple Numbers names the first table in a sheet
Table 1. To find the table name, open
the file in Numbers and check the tab label above the table.
For example, Table 1.
-
Select Total columns to count every column in
the table, including empty ones.
-
In the Store column count field, create or
select a Number variable.
For example, nColumnCount.
The variable stores the total number of columns. For the sample data,
this value is 7 (five data columns and two empty
columns).
-
Delete the empty columns generated by the export.
In the sample data, columns C and F are empty. Delete column F first, then
column C. Deleting in reverse order (rightmost first) prevents column
positions from shifting before you delete the next column.
-
Add a Delete rows/columns
action to the automation.
-
In the Session name field, enter
ExpenseCleanup.
-
Select Columns as the delete option, then select
Specific column.
-
In the Table name field, enter
Table 1.
-
In the Column name field, enter
F to delete the rightmost empty column
first.
-
Add a second Delete rows/columns action and
repeat the configuration, entering C in the
Column name field.
The two empty columns are removed. The spreadsheet now contains five
columns: Date, Department, Category, Amount, and Approved by.
-
Remove blank rows scattered throughout the data.
A blank row is a row where all cells are empty. The Remove blank
rows
action scans the table and deletes every blank row, which
consolidates the data into contiguous rows.
-
In the Actions panel, navigate to .
-
Double-click or drag the Remove blank rows
action to add it to the automation.
-
In the Session name field, enter
ExpenseCleanup.
-
Select the specific table option, then in the Table
name field, enter Table 1.
-
Leave the beginning and end row of the table options at their defaults
to scan the entire sheet for blank rows.
All blank rows are deleted. Only the header row and expense data rows
remain.
-
Get the total number of rows after cleanup.
You need the row count to determine where to insert the summary row. The
value returned by this action includes the header row.
-
In the Actions panel, navigate to .
-
Double-click or drag the Get number of rows
action to add it to the automation.
-
In the Session name field, enter
ExpenseCleanup.
-
In the Sheet name field, enter
Sheet 1.
-
In the Table name field, enter
Table 1.
-
Select Total rows to count every row, including
the header row.
-
In the Store row count field, create or select a
Number variable.
For example, nTotalRows.
The nTotalRows variable stores the number of rows in
the cleaned-up spreadsheet. For example, if the spreadsheet has a header row and
15 data rows, the value is 16.
-
Insert a new row below the last data row for the expense total.
-
In the Actions panel, navigate to .
-
Double-click or drag the Insert rows/columns
action to add it to the automation.
-
In the Session name field, enter
ExpenseCleanup.
-
Select Rows as the insert option, then select
Specific row.
-
In the Table name field, enter
Table 1.
-
In the Row number field, enter the row number
returned by the previous action.
For example, enter $nTotalRows$.
-
Select Add row below so the new row is inserted
immediately after the last data row.
A new empty row is added at the bottom of the data.
-
Add a total label and a SUM formula to the summary row.
Use the Set cell data
action to write values into specific cells. You add this action twice: one for the label and another one for the
formula.
-
In the Actions panel, navigate to .
-
Add the Set cell data
action to the automation.
-
In the Session name field, enter
ExpenseCleanup.
-
Select Value as the data type to set, then
select the specific cell option.
-
In the Table name field, enter
Table 1.
-
In the Cell address field, enter the cell
reference for the Category column in the summary row.
For example, if the summary row is row 17, enter
C17.
-
In the Value field, enter
TOTAL.
-
Add a second Set cell data
action, and select Formula as the
data type to set, then select the specific cell option.
-
In the Table name field, enter
Table 1.
-
In the Cell address field, enter the cell
reference for the Amount column in the summary row.
For example, D17.
-
In the Formula field, enter the SUM formula to
calculate the total of all expense amounts.
For example,
=SUM(D2:D16).
Adjust the cell range in the formula to match the actual number of
data rows in your spreadsheet. The range starts at D2 (the first
data row below the header) and ends at the row immediately above the
summary row.
The summary row displays the label TOTAL in the Category column and the
calculated expense total in the Amount column.
-
Save and close the expense report file.
-
In the Actions panel, navigate to
.
-
Double-click or drag the Close
action to add it to the automation.
-
Select the Save the changes before closing file
check box to save the file before closing.
-
In the Session name field, enter
ExpenseCleanup.
The file is saved with all cleanup changes applied and the session is
closed.
Results
The automation cleans up the raw expense report in a single run. The final
spreadsheet contains only the data columns (Date, Department, Category, Amount, and
Approved by), has no blank rows, and includes a summary row with the expense
total.