- There are three methods for generating QR codes in Excel: VBA functions, macros, and add-ins.
- With a custom function, you can insert the QR code directly into the cell where you type the formula.
- Macros allow you to automate the generation of multiple QR codes at once from a range of cells.
- Plugins are the simplest and most visual option, ideal for those who don't want to use code.
Do you need to generate QR codes directly from Excel And you don't know where to start? Don't worry, creating these codes is easier than it seems, and you can do it without installing external programs or getting too complicated. There are multiple ways to achieve this, from custom functions to using macros or add-ins.
In this article we explain How to generate QR codes in Excel step by step, with simple instructions applicable to any modern version of Excel. If you prefer to automate tasks or simply save time, this tutorial will be perfect for you.
What is a QR code and what is it used for in Excel?
The QR codes They are graphic representations that can store data such as text, links, numbers, emails, and more. When scanned with a mobile phone, the content is automatically displayed. Integrating them into Excel allows you to quickly share information such as links to documents, forms, customer records, contacts, or any other relevant data.
Method 1: Create QR codes with a custom function in VBA
The first option you have is to use a custom function written in VBA. It's easy to implement and allows you to generate QR codes directly from a cell.
First, activate the Developer tab
- Right click on the ribbon and select “Customize the ribbon".
- Check the box "Programmer" or "Developer".
- Click on Accept.
Next, create the custom function
- In the Developer tab, open Visual Basic.
- Insert a new module.
- Paste the following code:
Function CrearQR(texto As String, tamano As Integer) As Variant
Dim url As String
Dim celda As Range
Dim nombreImagen As String
Dim img As Shape
On Error GoTo ErrorHandler
If Trim(texto) = "" Then
CrearQR = CVErr(xlErrValue)
Exit Function
End If
Set celda = Application.Caller.Cells(1, 1)
nombreImagen = "QR_" & celda.Address(False, False)
On Error Resume Next
celda.Worksheet.Shapes(nombreImagen).Delete
On Error GoTo 0
url = "https://api.qrserver.com/v1/create-qr-code/?size=" & tamano & "x" & tamano & "&data=" & WorksheetFunction.EncodeURL(texto)
With celda.Worksheet.Pictures.Insert(url)
.ShapeRange.LockAspectRatio = msoFalse
.Height = tamano
.Width = tamano
.Top = celda.Top
.Left = celda.Left
.Name = nombreImagen
End With
CrearQR = "QR generado"
Exit Function
ErrorHandler:
CrearQR = CVErr(xlErrValue)
End Function
How to use the function in Excel
- In any cell write:
=CrearQR(A1;150)
to generate the QR based on the contents of cell A1. - press Enter and you will see your QR code appear on the sheet.
- You can drag this formula down or sideways to duplicate it in other cells.
Delete generated QR codes
- Go to Home > Search & Select > Go to Special.
- Choose Objects.
- press Suppress to remove all visually inserted QR codes.
Method 2: Use a macro to generate multiple QR codes
If you prefer to automate even more, you can use a macro that works in bulk on a range of cells. This is ideal if you have a long list and want to quickly convert the entire column into QR codes.
Insert this macro into a Module
Sub GenerarQrCode(rango As Range, tamaño As Integer)
Dim urlQR As String, celda As Range, textoCodigo As String
Dim img As Picture
Dim nombreQR As String
For Each celda In rango
textoCodigo = Trim(celda.Value)
If textoCodigo <> "" Then
urlQR = "https://api.qrserver.com/v1/create-qr-code/?size=" & tamaño & "x" & tamaño & "&data=" & WorksheetFunction.EncodeURL(textoCodigo)
nombreQR = "QR_" & celda.Address(False, False)
On Error Resume Next
celda.Worksheet.Pictures(nombreQR).Delete
On Error GoTo 0
Set img = celda.Worksheet.Pictures.Insert(urlQR)
With img
.ShapeRange.LockAspectRatio = msoFalse
.Name = nombreQR
.Left = celda.Left + 2
.Top = celda.Top + 2
.Height = tamaño
.Width = tamaño
End With
End If
Next celda
End Sub
Sub EjecutarGenerarQrCode()
Dim rango As Range
Set rango = Selection
Dim tamaño As Variant
tamaño = InputBox("Por favor, introduce el tamaño del código QR (ej. 150):", "Tamaño del código QR", 150)
If Not IsNumeric(tamaño) Or tamaño <= 0 Then
MsgBox "Tamaño inválido. Por favor ingresa un número mayor que cero.", vbExclamation
Exit Sub
End If
GenerarQrCode rango, CInt(tamaño)
End Sub
To use the macro
- Select the range of cells that contain the text or links.
- Run the macro “Run GenerateQrCode".
- Enter the desired size for the QR codes (for example 150).
Important: Save the file as .xlsm for macros to work correctly.
Method 3: Use official Excel add-ins
If you're not a fan of code or macros, don't worry. You can also opt for a much simpler solution: using an external add-in for Excel.
Steps to install the plugin
- From Excel, go to Insert > Add-ins > Get Add-ins.
- Type “QR” into the search engine and select one with a good rating (recommended: red icon).
- Click on Add and then Continue.
Generate QR with the plugin
- Select the cells that contain the data to be converted.
- Open the plugin and set the QR code size you want (for example, 100×100 px).
- press Generate.
This method is ideal if you don't want to mess with code or if you work in business environments where macros are blocked.
Why use QR codes in Excel?
- Process automation: Scan and access information directly without copying/pasting links.
- Ease of data sharing: from employee files to links to dashboards or online forms.
- Mobile compatible: may be made by each smartphone you can scan the code and access the content.
There are multiple ways to create QR codes in Excel to suit different work styles. Whether using VBA code, bulk macros, or visual add-ins, there's always an accessible option for you. All the solutions shown are free, effective, and compatible with recent versions of Excel, so you only need a little practice to master this tool, which is becoming increasingly useful in offices, schools, logistics, and more sectors.
Passionate writer about the world of bytes and technology in general. I love sharing my knowledge through writing, and that's what I'll do on this blog, show you all the most interesting things about gadgets, software, hardware, tech trends, and more. My goal is to help you navigate the digital world in a simple and entertaining way.