I have created a formula to insert country flags in Google Sheets’s cells. For this I’ve used IMAGE, IMPORTXML and SUBSTITUTE functions. In this formula we’re taking flag images from Wikipedia.
You can paste below formula in your Google Sheets:
=IMAGE(“https:”&IMPORTXML(“https://en.wikipedia.org/wiki/Gallery_of_sovereign_state_flags”,”//img/@src[contains(.,'”&SUBSTITUTE(A2,” “,”_”)&”‘ )]”))
Change A2 with the cell address in which you are typing country name. You need to type first letter of country name in capital letter in order this to work.
I have explained this formula in my below YouTube video. You can watch this video to understand how it works: