logo
search
VBA & Macro Problems

How to Automatically Display Country Flags and Maps in Excel

Kushani NimanthikaKushani Nimanthika Sep 28, 2026 869 views

Question details

The user needs a method to dynamically update and display specific images (national flags and maps) in a workbook based on the country selected.

How to Automatically Display Country Flags and Maps in Excel
Product
Excel
Device & OS
not provided
Scenario
Building an interactive workbook or dashboard where visual elements like maps and flags automatically change when a user selects a different country from a list.
Observed behavior
The goal is for the correct flag and map image to appear instantly on the screen corresponding to the country name chosen in a specific cell.
Before you start

Ensure all your country flag and map images are properly sized and inserted into your Excel workbook, and confirm that your version of Excel has macros enabled if you plan to use the VBA method.

Solution 1Recommended

Use VBA Worksheet_Change Event to Update Images

Write a short VBA macro that triggers automatically when a user selects a new country from a drop-down list, fetching the correct images.

Using a VBA Worksheet_Change event allows Excel to detect exactly when the drop-down cell is modified. The script then deletes the old image and pastes the new flag and map corresponding to the newly selected country.

This method is ideal for complex dashboards where you need exact control over image placement, sizing, and error handling.

1
Create a drop-down list

Select the cell for your country input on your main sheet. Go to the Data tab, click Data Validation, choose 'List', and input your country names.

2
Name your images

Insert your flags and maps into a separate, hidden sheet. Select each image and use the Name Box (top left corner of the Excel window) to name them exactly as they appear in your drop-down list (e.g., 'Flag_USA').

3
Insert the VBA code

Press Alt + F11 to open the VBA Editor. In the project explorer, double-click the worksheet containing your drop-down and paste a Worksheet_Change script that copies the matching shape name from your hidden sheet to your display area.

Use VBA Worksheet_Change Event to Update Images
Macro Security: You must save your workbook as a Macro-Enabled Workbook (.xlsm) for the VBA code to run correctly the next time you open the file.
Advanced Spreadsheet Editor

Create Interactive Dashboards with WPS Spreadsheet

WPS Office offers robust support for VBA macros and advanced formulas, making it incredibly easy to create dynamic workbooks that automatically update visual elements like flags and maps.

  1. 1. Download and Install WPS Office: Get WPS Office for free and open your workbook file in WPS Spreadsheet.
  2. 2. Enable Developer Tools: Navigate to the Developer tab and click on the 'Visual Basic' icon to access the VBA editor seamlessly.
  3. 3. Apply Macros or Formulas: Paste your dynamic image lookup VBA script or set up Named Ranges using the built-in Name Manager just as you would in standard Excel.
  4. 4. Save as Macro-Enabled: If you utilized VBA scripts, ensure you save your document in the .xlsm format to preserve the interactive map and flag features.
Fully compatible with Microsoft Excel (.xlsx and .xlsm) formatsComprehensive support for VBA macros and developer toolsAdvanced formula capabilities including INDEX, MATCH, and INDIRECTFree and lightweight alternative to heavy office suites
microsoft office alternative - wps office

Frequently Asked Questions

Why is my dynamic image not updating when I select a new country?

Ensure that formula calculation is set to Automatic in your workbook settings. If you are using the VBA method, check that macros are enabled in the Trust Center and that the Worksheet_Change event is correctly targeting your specific drop-down cell.

Do I need to resize every flag and map manually?

Yes, it is highly recommended to standardize the aspect ratio and size of all images beforehand. Alternatively, you can add lines in your VBA script to automatically set the '.Width' and '.Height' properties of the pasted image object.

Can I use dynamic images on a shared workbook?

If you are using the Linked Picture method with Named Ranges, it will generally work in shared environments. However, VBA macros often have restricted functionality in real-time co-authoring modes or web-based versions of spreadsheet software.