5 Ways to Insert a Country Flag in Excel Cell

Do you need to insert country flags in Excel cells?

This can help make geographic data reports more attractive and professional.

In today’s interconnected world, data is often global. It’s not uncommon to find spreadsheets filled with country-specific information or geo-specific datasets. Suppose you’re tracking international sales, analyzing global trends, or simply maintaining records with an international flavor, you might want to make your Excel sheets not just informative, but visually appealing as well.

One way to achieve this is by incorporating country flags into your Excel cells. These flags can serve as powerful visual cues, making your data more engaging and user-friendly. However, there isn’t any straightforward way to add country flags from a list of icons or flag images from the data library in Excel.

Instead, you can use various tools and functions of Excel to add country flags in Excel.

Read this Excel tutorial until the end as I show you various ways to insert regional flags in Excel using manual and automatic methods. Moreover, I’ll show advanced methods utilizing Excel VBA and Office Scripts so you can automate the process too. Let’s get started!

Reasons to Insert a Country Flag in Excel

Your primary motive for including country flags in an Excel worksheet is to enhance its visual qualities. Instead of just text names of countries, a flag helps you to attract the audience quickly.

Audiences from the related countries in your Excel worksheet will get emotionally connected with your reports or templates if they see the respective country flags.

Find below other major reasons to add country flags:

  1. Flags can serve as visual cues to quickly identify and associate data with specific countries, making your information more accessible.
  2. If you work with global data or conduct international business, flags can help you categorize and analyze information by country.
  3. In reports and presentations, flags can make your findings more visually appealing and easier to understand.
  4. Flags can provide cultural context, which is particularly useful when dealing with diverse audiences or multicultural data.
  5. Flags in educational spreadsheets can aid in geography lessons or cross-cultural studies.
  6. When you’re dealing with comparative data, such as country statistics, if you use flags you can make the differences and trends more apparent.

Microsoft Excel offers numerous tools, functions, and scripting capabilities that allow you to insert flags into your Excel workbooks without the need for an explicit ‘add flags’ button. Find below the smart ways you should try right now:

Add a Country Flag to an Excel Cell Manually

You can either manually place the flag image over the cell grid or within a cell.

Add Country Flag Over Cells

This method is just like inserting any image in Excel. However, in the current tutorial, I’ll show how you can insert the USA flag in a cell in an Excel cell. Now, you must source the flag yourself and download it as an image file, like JPEG or PNG. Here are the instructions you can follow:

Insert tab of Excel
Insert tab of Excel
  1. Run the Excel desktop app and open the workbook where you need to add country flags.
  2. Navigate to the specific cell within your worksheet where you want to insert the flag.
  3. Click on the Insert tab located in the Excel ribbon at the top of the application window.
  4. Within the Insert tab, locate and click on the Pictures option. This will open the Insert Picture From context menu.
  5. There, click on the This Device Option.
Inserting a Flag in Excel
Inserting a Flag in Excel
  1. On the Insert Picture dialog, navigate to the location where you’ve saved the flag image on your computer.
  2. Click the Insert button located at the bottom right corner of the dialog box.
Image inserted in Excel
Image inserted in Excel

Excel will insert the image instantly. However, it won’t resize the image to fit a cell or a range of merged cells. The flag will show up in its full resolution and size.

The image resizer pointers in an image in Excel
The image resizer pointers in an image in Excel

To resize it, click on the inserted flag. A set of points will show up on the edges of the image. Use those points to drag and resize the image. You can also drag by clicking the Ctrl key to resize the image from both sides at the same time.

Resized inserted flag to cell size
Resized inserted flag to cell size

Find above a screenshot of the resized country flag to the selected cell volume.

Add Country Flag In Cells

Microsoft shall introduce two new methods of importing images in Excel. Soon, you’ll find the Place in Cell and Place over Cells options in the Insert > Picture command of the Excel desktop app. You can experience it now by participating in the Microsoft 365 Insider program.

Here’s how to use this new Excel feature:

  1. Go to your worksheet, select the target cell for the country flag, and click the Insert tab.
  2. There, click on the Picture drop-down menu and hover the cursor over the Place in Cell option.
  3. Click on the This Device option in the overflow menu.
Selecting an image in Excel
Selecting an image in Excel
  1. Navigate to the country flag image you want to add using the Insert Tab dialog.
  2. Select the file and click Insert.

Excel will automatically insert the image and fit the Excel cell by keeping the aspect ratio. You don’t need to manually adjust the image file.

Insert a Country Flag in Excel Using Geography

The Data Types Geography tool in Excel is a hidden gem. It allows you to link names of places, cities, countries, regions, etc., to real-time online geography data. Then, you can extract related geographical data in another column, like population, gasoline price, area, GDP, and more. You can also use this feature to include the flag of the selected country or region.

Here’s how to use Data Types Geography to add country flags in Excel:

Data types Geography in Excel
Data types Geography in Excel
  1. Write down the name of the country in a cell of your Excel worksheet.
  2. Select the cell and click on Data > Data Types > Geography.
Converted Geo data and insert data icon
Converted Geo data and insert data icon
  1. Excel will take a moment to convert the text string into a geography data type and link it to online resources.
  2. A tiny Insert Data icon will show up above the selected cell.
Image list item in Geography data type
Image list item in Geography data type
  1. Click the Insert Data icon.
  2. On the context menu that shows up, scroll down to the Image list item and click on it.
Inserted country flag in Excel using Geo Data Type
Inserted country flag in Excel using Geo Data Type
  1. Excel shall insert the country flag right next to the selected cell.
  2. Excel shall also automatically adjust the country flag image to fit the cell.

Note: At the time of writing, the Data Types command in Excel is only available in Excel for the Microoft 365 desktop app and Excel for the web app. You can only use these Excel editions if you own a paid Microsoft 365 Business Standard or higher subscription.

Insert a Country Flag in Excel Using the IMAGE Function

If you want to insert country flags in Excel cells programmatically, you can use the IMAGE function. It allows you to add image source URL, image size, image height, and image width as Excel formula arguments.

Therefore, when you’re sourcing a country flag image from the internet, you can instruct Excel to resize the inserted image by adding height, width, and size arguments as numeric values.

This method is also specific to Excel for Microsoft 365 desktop and web app and requires a Business Standard subscription to use it. You should already have the feature if you’re accessing Excel as a part of a business or an organization.

Here’s how to utilize the IMAGE function:

Use IMAGE Function With Wikimedia URLs

Inserting a country flag using IMAGE function
Inserting a country flag using the IMAGE function
  1. Select a cell where you want to insert a country flag.
  2. Then, enter the following formula inside the cell:
=IMAGE("https://upload.wikimedia.org/wikipedia/en/thumb/a/a4/Flag_of_the_United_States.svg/1280px-Flag_of_the_United_States.svg.png","USA",1)
  1. Hit Enter and you’ll get the USA image flag.

Here’s how you can customize the above formula:

  • Put your own source of flag within the double quotes.
  • Insert image alt text within double quotes.
  • Enter a numeric 0 to insert the flag within the cell without changing the aspect ratio.
  • Alternatively, you can enter a numeric 1 to resize the image to fill the cell without conserving the aspect ratio.

When inserting the source URL, ensure the inserted hyperlink ends with any of these file extension codes: .PNG, .JPEG, .BMP, .GIF, .ICO, .WEBP, and .TIFF.

Use IMAGE Function With Flag CDN

You could find this challenging to source country flag URLs that end in a few selected file formats that Excel can render as an image. Hence, you can use the following CDN & API of flags by Flagcdn.com. This CDN link consists of 254 country flags in the PNG format.

Inserted a Canadian flag using a CDN server
Inserted a Canadian flag using a CDN server
https://flagcdn.com/48x36/ca.png 

The above link will insert the country flag of Canada. To insert a different country flag change the URL code ca to the alpha-2 code of the target country like us, za, uk, etc. You must type the alpha-2 code for a country in small letters.

The steps to use the above link are the same as the steps mentioned in the above Wikimedia section.

Use the IMAGE Function and Flag Emojis

Follow these steps to insert country flags in Excel cells using emoji flags:

Sourcing emoji code for flag
Sourcing emoji code for AR flag
  1. Get emoji codes for the country flags you must insert in an Excel worksheet.
  2. You can visit Emojipedia to source emoji flags.
Copying and pasting emoji code in Excel
Copying and pasting emoji code in Excel
  1. Copy and paste the emoji code for a country flag in B3.
Insert country flag using emoji code
Insert country flag using emoji code
  1. Now, go to the target cell and enter the following formula in it:
=IMAGE("https://emoji.beeimg.com/"&B3&"/250/twitter")
  1. Hit Enter.
  2. Excel will add the country flag that you mentioned in cell B3.

If you need to insert many country flags, source the emoji codes for those country flags in a column. Then, copy and paste the above function in the adjacent cell for the corresponding country flags. You’ll effortlessly insert hundreds of country flags in a few seconds.

Insert Country Flag in Excel Using Excel VBA

Imagine the task of seamlessly integrating more than 100 country flag images from a local directory on your computer into an Excel worksheet. In this worksheet, the country names are organized neatly in a column.

Your objective is to automatically position the flag images right alongside their respective country names by expertly synchronizing the content from your designated folder with the entries in the worksheet column.

If you attempt to do this using any of the methods mentioned earlier you’d need to invest hours. Instead, you can use Excel VBA to automate the process. All you need to do is save the country flag images in the same name string as the country names that appear on the Excel worksheet.

If you’re ready with the flag images and the Excel worksheet, let’s begin with these steps:

An Excel VBA script to insert flag images
An Excel VBA script to insert flag images
  1. Press Alt + F11 to launch the Excel VBA Editor.
  2. Click the Insert button on the VBA Editor toolbar.
  3. Choose Module from the context menu that opens.
  4. In the new module, copy and paste the following Excel VBA script:
Sub InsertFlagImages()
    Dim ws As Worksheet
    Dim cell As Range
    Dim flagPath As String
    Dim flagFileName As String
    Dim flagLeft As Double
    Dim flagTop As Double
    Dim flagWidth As Double
    Dim flagHeight As Double
    
    ' Set the worksheet where you want to insert the flag images
    Set ws = ThisWorkbook.Sheets("Sheet2")
    
    ' Loop through the country names in column A
    For Each cell In ws.Range("A2:A8")
        ' Construct the full file path to the flag image
        flagFileName = cell.Value & ".png"
        flagPath = "C:\Users\CtOS\Downloads\Flags\" & flagFileName
        
        ' Check if the image file exists
        If Dir(flagPath) <> "" Then
            ' Define the position and size of the image
            flagLeft = cell.Offset(0, 1).Left
            flagTop = cell.Offset(0, 1).Top
            flagWidth = cell.Width
            flagHeight = cell.Height
            
            ' Insert the image in the adjacent cell in column B
            ws.Shapes.AddPicture flagPath, msoFalse, msoTrue, flagLeft, flagTop, flagWidth, flagHeight
        Else
            ' If the image file does not exist, handle the error as you see fit
            MsgBox "Flag image for " & cell.Value & " not found."
        End If
    Next cell
End Sub
  1. Click the Save button on the toolbar.
  2. Now, close the Excel VBA Editor interface.

Here’s how you can customize the above script:

  • In code element ThisWorkbook.Sheets("Sheet2"), change Sheet2 to the exact worksheet name.
  • Change the cell range from A2:A8 in the code element ws.Range("A2:A8") to the actual cell range of your worksheet where you got country names.
  • In the code element cell.Value & ".png", change the file extension .png to the source file extensions like .jpg, .jpeg, etc.
  • For the code element flagPath = "C:\Users\CtOS\Downloads\Flags\" change the flag file location according to your own local directory.
Macro dialog box
Macro dialog box

To execute the script, press Alt + F8 and choose InsertFlagImages macro in the Macro dialog box. Hit the Run button to automatically insert the flag images.

Insert country flag using Excel VBA
Insert country flag using Excel VBA

Find above a screenshot of the result of the above Excel VBA script. This method isn’t available on Excel for the web or Excel online apps.

Insert Country Flag in Excel Using Office Scripts

If you wish to automate the insertion of country flags using Microsoft Power Automate and Excel, you need to use Office Scripts. This method is applicable to both Excel for the Microsoft 365 desktop and Excel for the web app.

Find below a script and the instructions to use it:

Using Office Scripts to insert flag in Excel
Using Office Scripts to insert flag in Excel
  1. Click the Automate tab.
  2. Inside the Scripting Tools block, click on the New Script button.
  3. Copy and paste this script inside the Code Editor:
function main(workbook: ExcelScript.Workbook) {
	let selectedSheet = workbook.getActiveWorksheet();
	// Paste string at cell range B2 on selectedSheet
	selectedSheet.getRange("B2").setFormulaLocal("=IMAGE(\"https://flagcdn.com/48x36/us.png\",\"US\",0)");
	// Set range B3:B5 on selectedSheet
	selectedSheet.getRange("B3:B5").setFormulasLocal([["=IMAGE(\"https://flagcdn.com/48x36/gb.png\",\"GB\",0)"],["=IMAGE(\"https://flagcdn.com/48x36/fr.png\",\"FR\",0)"],["=IMAGE(\"https://flagcdn.com/48x36/ca.png\",\"CA\",0)"]]);
}
  1. Click the Save script button.
  2. Now, click the Run button.

Excel will automatically insert country flags for USA, GB, France, and Canada in the cell range B2:B5 by downloading flag images from the Flagcdn portal.

Here’s how you can customize the script:

  • Change all instances of cell reference B2 to another cell reference from which you want to start populating the country flags, like C2, D2, etc.
  • Change the URL in the IMAGE function to insert different country flags than the ones inserted in this tutorial.
  • Modify the cell range B3:B5 to a different range where you want to copy the IMAGE function. For example, C3:C5 instead of B3:B5.
  • To insert more flags you need to copy and edit the IMAGE function for extra cells you want to add.

Conclusions

In the world of data, the ability to communicate information effectively is a priceless skill, and one way to do that is by adding visual elements to your spreadsheets. Adding flags to geographical data in Excel is one such skill.

In this guide, you learned various ways to insert flag images into cells in your Excel worksheet. You can use the manual image insert method if you do this occasionally. Or, you can automate the process by using methods like the IMAGE function, Data Types Geography function, Excel VBA, and Office Scripts.

Don’t forget to comment below mentioning your experience of using the above methods or to inform me of an easier and intuitive method that I might have missed.

About the Author

Bipasha Nath

Bipasha Nath

Bipasha is a technical content writer with 10+ years of experience in the technology industry. She previously worked in a SaaS software development company focused on SharePoint, OneDrive, Word, Excel, Word solutions.

Related Posts

Comments

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Get the Latest Microsoft Excel Tips

Follow Us

Follow us to stay up to date with the latest in Microsoft Excel!

Subscribe for awesome Microsoft Excel videos 😃