=NOMOR_HP(phone) – one format for phone numbers
Apps Script recipes › Sheet formulas
"0812-3456-7890" and "+62 812 3456 7890" both become 6281234567890, the form WhatsApp links need.
Use it in a Google Sheet
After saving the code in a script bound to the spreadsheet, type =NOMOR_HP(A2) in a cell. It works on one cell or a range.
File Code.gs
/**
* Writes a phone number as 62… digits.
* @param {string} phone A phone number, or a range of them.
* @param {boolean} [link] TRUE for a https://wa.me/ link.
* @return Digits like "6281234567890".
* @customfunction
*/
function NOMOR_HP(phone, link) {
if (Array.isArray(phone)) return phone.map(row => row.map(v => NOMOR_HP(v, link)));
let d = String(phone === null ? '' : phone).replace(/\D/g, '');
if (!d) return '';
if (d.startsWith('0')) d = '62' + d.slice(1);
else if (d.startsWith('8')) d = '62' + d;
if (d.length < 9 || d.length > 15) return '';
return link === true ? 'https://wa.me/' + d : d;
}
Good to know
- =NOMOR_HP(A2; TRUE) gives a wa.me link instead of the number.
- Only Indonesian numbers are rewritten; other country codes are kept as they are.
Let the AI put it in your appGAS AI Builder knows every recipe here. Describe your app and it uses this code where it fits, in a Google Apps Script project in your own Drive.
Use it in a projectMore in Sheet formulas
=EMAIL_VALID(text) – check email addressesTRUE when the text looks like an email address; catches spaces, missing @ and common typos like gmial.com.
=EMAIL_VALID()=HARI_KERJA_LIBUR(start; end; holidays) – working days with a holiday tabCounts working days between two dates, skipping the holidays listed in a range; =HARI_KERJA_LIBUR(B2; C2; Libur!A:A; 6) counts Saturdays as work days.=HARI_KERJA_LIBUR()=JSON_GET(json; path) – read a value from JSON in a cell=JSON_GET(A2; "customer.name") or "items.0.price" pulls one value out of JSON stored in a cell.=JSON_GET()=RUPIAH(amount) – "Rp 1.250.000" as textFormats a number as rupiah text with dots between thousands, for labels, emails and documents made from the Sheet.=RUPIAH()=SLUG(text) – short ids from names"Kopi Susu Gula Aren (Large)" becomes "kopi-susu-gula-aren-large", for codes, file names and links.=SLUG()=TANGGAL_INDO(date) – "Selasa, 3 November 2026"Writes a date with Indonesian day and month names; =TANGGAL_INDO(A2; FALSE) leaves out the day name.=TANGGAL_INDO()