What is pinyin

Pinyin is a system for representing Chinese phonetically, and is used to romanize chinese script for publication or learning, and in particular for entry with a standard keyboard. You will notice in the example below that many of the vowels are marked with 'diacritics'. These are markers used to indicate the 'tone' to apply to the syllable

Coloring

Entering the tone markers on a keyboard would be a challenge, so another method is to use tone numbers, 1-4, each of which represent one of the possible tones of mandarin. Here's the same thing using tone numbers.

They are designed to be used as custom functions - typically called something like =pinyinToToneMarks(A2)

The code

It was a little more complicated to implement this in VBA, since regex is heavily used for parsing and VBA is not so good as javaScript for that or object handling. The code is in pinyin.xlsm in the Downloads section or you can pull it directly in your project using gistThat