=TERBILANG(amount) – numbers in Indonesian words
Apps Script recipes › Sheet formulas
=TERBILANG(1250000) gives "satu juta dua ratus lima puluh ribu rupiah". Works on a whole column too.
Use it in a Google Sheet
After saving the code in a script bound to the spreadsheet, type =TERBILANG(A2) in a cell. It works on one cell or a range.
File Code.gs
const SATUAN_ = ['', 'satu', 'dua', 'tiga', 'empat', 'lima', 'enam', 'tujuh', 'delapan', 'sembilan', 'sepuluh', 'sebelas'];
function kata_(n) {
if (n < 12) return SATUAN_[n];
if (n < 20) return kata_(n - 10) + ' belas';
if (n < 100) return kata_(Math.floor(n / 10)) + ' puluh ' + kata_(n % 10);
if (n < 200) return 'seratus ' + kata_(n - 100);
if (n < 1000) return kata_(Math.floor(n / 100)) + ' ratus ' + kata_(n % 100);
if (n < 2000) return 'seribu ' + kata_(n - 1000);
if (n < 1e6) return kata_(Math.floor(n / 1000)) + ' ribu ' + kata_(n % 1000);
if (n < 1e9) return kata_(Math.floor(n / 1e6)) + ' juta ' + kata_(n % 1e6);
if (n < 1e12) return kata_(Math.floor(n / 1e9)) + ' miliar ' + kata_(n % 1e9);
return kata_(Math.floor(n / 1e12)) + ' triliun ' + kata_(n % 1e12);
}
/**
* Writes a number in Indonesian words.
* @param {number} amount The number, or a range of numbers.
* @param {boolean} [rupiah] FALSE to leave out "rupiah".
* @return The number in words.
* @customfunction
*/
function TERBILANG(amount, rupiah) {
if (Array.isArray(amount)) return amount.map(row => row.map(v => TERBILANG(v, rupiah)));
if (amount === '' || amount === null) return '';
const n = Math.round(Number(amount));
if (isNaN(n)) return '';
const words = n === 0 ? 'nol' : (n < 0 ? 'minus ' : '') + kata_(Math.abs(n));
return words.replace(/\s+/g, ' ').trim() + (rupiah === false ? '' : ' rupiah');
}
Good to know
- =TERBILANG(A2; FALSE) leaves out the word "rupiah".
- Decimals are rounded to whole rupiah.
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()=NOMOR_HP(phone) – one format for phone numbers"0812-3456-7890" and "+62 812 3456 7890" both become 6281234567890, the form WhatsApp links need.=NOMOR_HP()=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()