BlogReference

=TERRITORY(): How to split sales territories in Google Sheets

6 July 2026·8 min read

To split sales territories in Google Sheets, use the =TERRITORY() function from the InstaMaps add-on. Point the formula at a range of geographic coordinates, specify the number of zones required, and it assigns each location to a balanced region directly inside your spreadsheet cells.

This workflow is built for regional sales managers and field service dispatchers handling large prospect lists. By combining the formula with standard spreadsheet filtering, teams can divide 200-home farm areas or 47-stop route lists into equal sections, ensuring fair distribution of leads across five representatives.

TL;DR
  • The =TERRITORY() formula assigns fair geographic zones from a list of coordinates.
  • Syntax requires a two-column range of coordinates and the number of desired territories.
  • The InstaMaps add-on provides 100 lookups per day on the free tier (1,000/day with a free email unlock).
  • Use the Extensions > InstaMaps > Enable formulas sidebar to insert formulas without typing.
  • Combine =TERRITORY() with =INSTAMAP() to generate a live map URL of your newly split sales zones.

Syntax and arguments

`=TERRITORY(coordinates_range, number_of_zones)`

Creates fair geographic zones from a list of coordinates using a k-means clustering algorithm. This assigns a territory number to each location, balancing the number of accounts per zone and minimising travel distance.

| Argument | Description | | :--- | :--- | | `coordinates_range` | The range of cells containing the latitude and longitude pairs to group. The range must contain exactly two columns (latitude, longitude) in that order. Accepted values include direct cell references like `A2:B151` or outputs from the `=GEOCODE()` function. | | `number_of_zones` | The number of distinct territories to generate. This must be a whole number greater than zero. For example, entering `5` divides the coordinates into five balanced zones. |

  1. `=TERRITORY()` outputs an array of territory numbers (1, 2, 3, etc.) corresponding to each input row.

  2. The formula requires numeric coordinate data. If the `coordinates_range` contains text addresses, use `=GEOCODE(A2:A151)` in adjacent columns first, then point `=TERRITORY()` at the generated coordinates.

  3. If the `number_of_zones` argument exceeds the number of valid rows in your `coordinates_range` (for example, asking for 10 zones from a list of only 8 locations), the formula will return a `#NUM!` error.

  4. The resulting territory numbers can be passed directly into `=INSTAMAP()` to visually separate reps or regions using the colour-by-column feature.

How to split sales territories in Google Sheets

Follow these steps to apply the formula using the InstaMaps sidebar without manual typing.

  1. 1. Open your Google Sheet containing latitude and longitude data. If you only have physical addresses, select the address column and click **Extensions > InstaMaps > Enable formulas**.

  2. 2. In the InstaMaps sidebar, scroll to the Location formulas section and click **GEOCODE**. Highlight your address range (e.g., `A2:A151`) and run the formula to generate two new columns of coordinates.

  3. 3. With the coordinates generated, return to the InstaMaps sidebar and select the **TERRITORY** function.

  4. 4. Highlight the `coordinates_range` in your sheet, ensuring you select both the latitude and longitude columns (for example, `B2:C151`).

  5. 5. Enter your desired `number_of_zones` in the sidebar input box. If you have five sales reps, type `5`.

  6. 6. Click **Insert formula**. The add-on will populate the adjacent column with territory numbers from 1 to 5.

  7. 7. To visualise the split, highlight the full dataset-including the new territory column-scroll to the Map formulas section in the sidebar, and click **INSTAMAP**.

  8. 8. Alternatively, click the **Build-the-workflow** button in the sidebar to automatically chain the geocoding, territory splitting, and map generation steps together.

Worked example 1: 150 accounts across 5 reps

Consider a B2B sales team managing 150 existing accounts. The addresses are listed in `A2:A151`. The goal is to divide these 150 accounts evenly among 5 field sales reps to minimise overlapping travel.

First, geocode the accounts. In cell `B2`, enter `=GEOCODE(A2:A151)`. This fills columns B and C with latitude and longitude pairs.

Next, apply the territory logic. In cell `D2`, enter: `=TERRITORY(B2:C151, 5)`

Column D will now display numbers 1 through 5. The k-means clustering ensures that accounts physically close to each other share the same territory number, keeping each of the 5 reps confined to a specific geographic block rather than overlapping.

If an address in `A85` is malformed and fails to geocode, `=TERRITORY()` will automatically ignore the missing or error value in that row and continue processing the remaining valid coordinates.

Because the `=INSTAMAP()` function returns a live hosted shareable map URL that updates when the sheet changes, you can visualise these boundaries immediately. In cell `E2`, enter: `=INSTAMAP(A2:E151)`

InstaMaps will generate a link in cell `E2`. Opening this link displays a map of all 150 accounts. The map automatically colours the points based on column D (Territory). Rep 1 sees their blue cluster, Rep 2 sees their red cluster, and management can confirm the boundaries are geographically compact. If 15 new accounts are added to rows 152 through 166, simply drag the formulas down. The territory assignments recalculate, and the shared map updates automatically.

The free tier provides 100 lookups per day (1,000/day with a free email unlock), which provides sufficient capacity to process this 150-account list and map it daily.

Worked example 2: 45 franchise locations into 3 regions

A regional manager needs to group 45 franchise locations into 3 operational regions for auditing purposes. The latitude and longitude data for these locations are already formatted in columns B and C, spanning `B2:C46`.

To create the three regions, the manager places the following formula in cell `D2`: `=TERRITORY(B2:C46, 3)`

This spills territory numbers (1, 2, and 3) down column D, from cell `D2` to `D46`. Instead of splitting the franchises strictly by state lines or postal codes-which might result in uneven workloads-this splits them by physical proximity, creating three balanced geographic clusters.

To assign these regions to specific auditors, the manager can reference the output in a basic `IFS` statement. For instance, in cell `E2`, they might write: `=IFS(D2=1, "North Auditor", D2=2, "South Auditor", D2=3, "West Auditor")`

To generate a visual reference for the auditors, the manager creates a map link in cell `F2`: `=INSTAMAP(B2:F46)`

The resulting live map displays the 45 locations, shaded by their assigned region. Because the map formula pulls from the dynamic `=TERRITORY()` output, adjusting the `number_of_zones` argument later-such as expanding to 4 auditors by changing the formula to `=TERRITORY(B2:C46, 4)`-instantly updates both the text assignments and the visual map.

Worked example 3: 200 home plots into 4 field crews

A common use case is distributing property inspections across a field team. A solar farm inspection company has a list of 200 residential plots located in columns A and B (latitude and longitude). The operations manager needs to divide these evenly among 4 inspection crews to balance daily workloads.

Instead of drawing arbitrary borders on a paper map, you use the formula `=TERRITORY(A2:B201, 4)`. The function calculates the mathematical centre of the 200 points and generates four distinct, contiguous geographic zones. It accounts for dense clustering naturally. If 120 of the 200 homes are situated tightly within a single suburban housing development, the formula assigns that entire cluster to Crew 1 and Crew 2 (roughly 60 homes each).

Crew 3 receives a zone covering 50 homes spread across a wider rural area to the north. Crew 4 receives the remaining 30 outlier properties located to the south. The output in column C will return territory numbers 1, 2, 3, and 4. You can then filter the sheet by these assigned numeric values to print physical daily manifests for each crew.

Common errors

If your cell returns a `#NAME?` error, Google Sheets cannot find the InstaMaps custom function. This occurs when the add-on is not installed, when it is disabled, or if you have a typo in the function name. Check that you typed the function exactly as `=TERRITORY()` without any spelling variations or extra letters. To resolve the missing add-on, install InstaMaps or navigate to Extensions > InstaMaps > Enable formulas. You can read our guide on the google-sheets-geocode-formula post for step-by-step instructions on fixing custom function installations.

Quota limits are the second most common issue. InstaMaps provides a free tier of 100 lookups per day, which expands to 1,000 lookups per day with a free email unlock. If you attempt to process a list of 250 coordinates at once on the base free tier, the cells exceeding the 100th row will display the message: `Error: Daily quota exceeded (100/100). Free tier limit reached.` If you encounter this message, wait 24 hours for the midnight Pacific Time quota reset, or complete the free email unlock inside the InstaMaps sidebar to increase your daily processing capacity to 1,000 rows.

Composes with: Real workflow chains

The `=TERRITORY` function rarely operates in isolation. It is designed to slot into larger data processing chains within your spreadsheet. The sidebar's Build-the-workflow button writes these exact chains for you without manual typing.

  1. **Chain 1: Geocoding addresses before splitting them**

  2. `=TERRITORY` requires raw coordinates, not text addresses. If your source data in column A is a list of physical street addresses, you must convert them first.

  3. Step 1: In column B, run `=GEOCODE(A2:A201)` to generate decimal coordinates for your 200 rows of text addresses.

  4. Step 2: Filter out or correct any rows in column A that returned an `#ERROR!` in column B, as `=TERRITORY()` requires clean numeric pairs to successfully build geographic zones.

  5. Step 3: In column D, run `=TERRITORY(B2:C201, 4)` to read those coordinates and assign the four geographic zones.

  6. **Chain 2: Turning territories into shareable URLs**

  7. Once you assign your territories, you need to distribute them to your field crews on their mobile devices.

  8. Step 1: In column D, you have your assigned zones (Territory 1, Territory 2) generated by `=TERRITORY(B2:C201, 4)`.

  9. Step 2: In cell F2, generate a live, hosted map URL using `=INSTAMAP(A2:A201, D2:D201)`. This produces a shareable link that plots the 200 homes, automatically colour-coding the pins by their assigned territory column.

  10. Step 3: Crews click the URL in cell F2 to see their stops routed geographically. Because `=INSTAMAP()` reads live sheet data, if you update a territory assignment in column D, the hosted map updates instantly without needing to resend the link.

Limits, honest alternatives, and who this is for

The `=TERRITORY` function assigns zones mathematically based on straight-line geographic centroids. It does not account for driving times, physical terrain barriers like rivers or canyons, or local traffic patterns. Additionally, the processing limit caps at 1,000 lookups per day. If you attempt to run this formula on 5,000 rows of coordinates, you will hit the quota ceiling and stall the calculation.

If you are dividing routes for a fleet of 50 delivery vans and need to optimise based on driving hours, road closures, and vehicle weight restrictions, Google Sheets is the wrong tool. You should switch to dedicated GIS software like QGIS or paid routing platforms like Route4Me. InstaMaps is built for lightweight, visual data analysis, not complex logistics modelling.

  1. **Who this is for:**

  2. Small sales managers: You have a list of 300 leads and need to draw three equitable lines on a map for your regional reps without buying enterprise software.

  3. Field service dispatchers: You manage 4 to 10 crews and need to quickly separate a spreadsheet of 150 service appointments into distinct geographic zones to balance workloads.

  4. Local marketers: You want to segment a customer database by neighbourhood to distribute door-hangers or direct mailers across four distinct postal sectors.

  5. If your data lives in Google Sheets and you need immediate, visual geographic zones without learning complex GIS software, this function handles the task precisely.

Try it free

Map your Salesforce accounts in under 5 minutes — no admin setup.

Install Free →

Common Questions

How do I split data by territory in Google Sheets?

Install the InstaMaps add-on via the Google Workspace Marketplace, then click Extensions > InstaMaps > Enable formulas to open the sidebar. Select your address data, for example A2:A400, and apply the =TERRITORY() function to generate a numerical or alphabetical zone assignment for each row. You can then use standard Google Sheets filters to sort representatives by their assigned zones.

What is the =TERRITORY() formula in InstaMaps?

It is a custom function that groups geographic coordinates into balanced clusters based on physical proximity. Instead of drawing polygons manually, you input a two-column range of latitudes and longitudes alongside a designated number of divisions. The add-on processes the coordinates and outputs a zone identifier for each specific location.

Why does my formula return a #NAME? error?

A #NAME? error indicates that Google Sheets cannot read the custom function text, which happens when the InstaMaps add-on is not installed or enabled in the current document. You must install the add-on from the Google Workspace Marketplace and ensure you activate it via the Extensions menu. Once the add-on is linked to your sheet, the formula will calculate correctly.

What happens if my coordinates are missing or invalid?

If the coordinates_range includes blank cells, text, or error values instead of clean numeric latitude/longitude pairs, the =TERRITORY() formula will ignore those specific rows or return an error. Always ensure that your =GEOCODE() step has fully completed and no #ERROR! values are present in the range before executing the territory split.

How many territories can I create in one formula?

You can generate up to 26 distinct sales territories within a single formula execution, which covers the vast majority of regional distribution models. The free tier allows processing 100 lookups per day, which increases to 1,000 daily lookups when you verify a free email address. If you need to process a list of 5,000 addresses, you will need to split your data across multiple days or request a higher quota.

Can I visualise the split territories on a live map?

Yes, you can pass your newly assigned territory data into the =INSTAMAP() function to generate a live hosted shareable map URL. By colour-coding the map markers based on the territory column, you will instantly see distinct geographic borders drawn around your specific sales clusters. This provides a clear visual confirmation that your zones are evenly distributed.

Does the map update when I add new sales leads?

Yes, the live hosted shareable map URL produced by =INSTAMAP() updates automatically when you add new sales leads to your sheet. If you append 50 new rows of addresses at row 401 and drag down your =TERRITORY() formula, the map will adjust its boundaries to include the newly assigned locations without requiring any manual refresh.

Build fair sales zones automatically

Stop drawing arbitrary lines on static maps. Use InstaMaps to group coordinates into balanced geographic clusters and visualise them instantly.

Install InstaMaps free