How to Generate Dynamic QR Codes in Microsoft Excel Using the IMAGE Function

Whether managing warehouse inventory batches, generating event registration badges, creating product label catalogs, or sharing direct Wi-Fi credentials, embedding scannable QR codes inside spreadsheets is a standard operational requirement. Previously, generating QR codes in Excel required third-party commercial add-ins, unstable VBA macros, or manual copy-pasting from online generators. With modern Excel’s native IMAGE and ENCODEURL functions, you can generate crisp, dynamic QR codes directly inside standard spreadsheet cells using a single lightweight formula.

How the Excel In-Cell QR Code Formula Works

This technique combines two native Microsoft Excel formulas with a public, HTTPS-compliant QR code rendering API (such as the reliable open-source QR Server API):

  • ENCODEURL(text): Converts raw cell text, web URLs, or inventory strings into URL-safe UTF-8 encoded parameters, properly escaping spaces, ampersands, slashes, and special symbols.
  • IMAGE(source_url, [alt_text], [sizing], [height], [width]): Fetches the rendered PNG image directly from the secure endpoint and docks it inside the cell boundary as a native in-cell graphic object.

The Core Formula Syntax

To generate an in-cell QR code for data residing in cell A2, enter the following formula into cell B2:

=IMAGE("https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=" & ENCODEURL(A2))

As soon as you press Enter, Excel sends the encoded string to the API and renders a clean, scannable 150×150 pixel QR code directly inside the cell. If you edit the contents of cell A2, the QR code in cell B2 recalculates and updates instantaneously.

Step-by-Step Guide: Building a Bulk QR Code Generator in Excel

Follow these steps to set up an automated QR code table that scales across hundreds of rows:

  1. Open a new or existing workbook in Microsoft Excel (Microsoft 365 or Excel for the web).
  2. Create your data input columns. For example:
    • Column A: Product SKU / Web URL (e.g., https://digitash.com/sample-product)
    • Column B: Item Name (e.g., Wireless Barcode Scanner)
    • Column C: QR Code
  3. In cell C2, input the formula:
    =IMAGE("https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=" & ENCODEURL(A2), A2, 0)
  4. Adjust row height and column width to give the QR code adequate breathing room. A row height of 80 to 100 points and a column width of 15 to 20 ensures high visual clarity.
  5. Double-click the fill handle in the lower right corner of cell C2 to copy the formula down your entire table. Excel populates individual, uniquely scannable QR codes for every row in your dataset.

Practical Example 1: Creating a Direct URL QR Code

If you want users to scan a code that takes them straight to a customer support portal or product user manual:

=IMAGE("https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=" & ENCODEURL("https://example.com/manual/" & A2))

Practical Example 2: Generating a “Scan to Email” QR Code

You can structure the input string to trigger an automated email draft when scanned by a smartphone camera:

=IMAGE("https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=" & ENCODEURL("mailto:[email protected]?subject=Inquiry for " & A2))

Practical Example 3: Generating a Wi-Fi Access QR Code

To print guest Wi-Fi connection cards directly from Excel:

=IMAGE("https://api.qrserver.com/v1/create-qr-code/?size=180x180&data=" & ENCODEURL("WIFI:S:" & A2 & ";T:WPA;P:" & B2 & ";;"))

Where A2 contains the Wi-Fi Network SSID and B2 contains the WPA2 password.

Customising QR Code Sizing, Formatting, and Printing

The IMAGE function includes an optional sizing parameter that dictates how the graphic responds to cell resizing:

  • 0 (Fit to cell – default): Maintains the image aspect ratio while scaling to fit cell dimensions.
  • 1 (Fill cell): Stretches the image to fit the exact cell borders (not recommended for QR codes, as stretching can hinder barcode scanner readability).
  • 2 (Original size): Displays the image in its original pixel dimensions, which may overflow cell boundaries if the row height is small.
  • 3 (Custom dimensions): Allows you to declare specific pixel heights and widths directly as additional formula arguments.

Tips for High-Scannability and Printing

  • High Contrast: Avoid applying dark background fills to QR code cells; smartphone cameras require sufficient white margin contrast (quiet zone) around the barcode to scan accurately.
  • Print Layout: In Excel’s Page Setup dialog, verify that gridlines and row formatting preserve square proportions so the printed output remains easily decipherable by laser scanners and mobile devices.

Leveraging native Excel in-cell formulas for dynamic QR codes completely removes the need for cumbersome external plugins, allowing teams to automate inventory labeling, event tickets, and product catalogs effortlessly.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.