
This guide explains how to use "PhoneFormatter," a convenient Google Apps Script (GAS) library that allows you to batch-format international phone numbers in a Google Sheet. Easily convert numbers into their proper, hyphenated format simply by providing a country name in English, Japanese, or even abbreviated form.


This is a Google Apps Script library for batch-formatting phone numbers in a Google Sheet to the appropriate format (e.g., with hyphens) based on their country.
The library reads phone number and country name data from specified columns in a sheet and writes the formatted phone numbers to a designated output column.
formatSpreadsheet(sheetName, phoneCol, countryCol, outputCol, startRow)
Formats the phone numbers within a spreadsheet.
Parameters:

Return Value:
Integer: Returns the number of phone numbers processed.Note on Country Names:
Japan), abbreviations (e.g., US), or in Japanese (e.g., 日本).+ icon next to "Libraries."1kL3K8a9qUz4yQWTNls0arDHy6bkhmtqeseWp4uYxXFjL9Fjy6ADR6VIU
PhoneFormatter).Use the sample code below, modifying the parameters to fit your sheet's layout.
JavaScript
function formatPhoneNumbers() {
// Configure the parameters
// 1. Sheet Name: The name of the sheet containing the phone numbers.
// 2. Phone Column: The column with the phone numbers (1 for A, 2 for B, etc.).
// 3. Country Column: The column with the country names (1 for A, 2 for B, etc.).
// 4. Output Column: The column where formatted numbers will be placed (1 for A, 2 for B, etc.).
// 5. Start Row: The row number where your data begins (e.g., 1 if there's no header).
var count = PhoneFormatter.formatSpreadsheet('Sheet1', 1, 2, 3, 1);
// Log the number of processed items
console.log(count + ' phone numbers were processed.');}
formatPhoneNumbers.
No, it is not. This is a third-party Google Apps Script (GAS) library (an externally developed program). To use it, you must open the Script Editor, add the library using the specified "Script ID" as per the instructions in Step 1, and set up an execution function (e.g., formatPhoneNumbers) yourself, like the code example in Step 2.
No, you must specify them using numbers. As noted in the comments of the code example in Step 2 (A column is 1, B column is 2...), the columns for the phone number (phoneCol), country (countryCol), and output (outputCol) are specified with numbers, where column A is 1, column B is 2, column C is 3, and so on.
No, it will not be overwritten. This function reads the data from the phoneCol (phone number column) and writes the formatted result to the separate column you specified as the outputCol (output column). The data in the original phone number column remains unchanged.
We can customize this sample to match your specific business requirements.
Book Free Consultation