How to Create QR Code Based on Cell Value in Excel


To convey information quickly and effectively, QR codes are becoming more and more popular. Excel offers a strong foundation to automate the process whether you want to generate QR codes for product labels, event tickets, or any other reason. In this tutorial, we'll look at detailed methods for making QR codes off of Excel cell values.

You will have a thorough understanding of the tools and methods required to generate QR codes dynamically based on the information in your Excel spreadsheet by the end of this tutorial. We'll go over everything you need to produce QR codes with ease, from adding the appropriate add−ins to creating the essential formulas. Let's start by revealing Excel's ability to make creating QR codes simpler, saving you time and effort while streamlining your workflow.

Creating QR Code Based on Cell Value

Here we will first check for Microsoft Barcode Control 16.0, then insert a VBA module, and then add the code to a button to complete the task. So let us see a simple process to learn how you can create QR codes based on cell values in Excel.

Step 1

Consider an Excel sheet.

First, click on "Developer" and "More Controls," and verify whether you have Microsoft Barcode Control 16.0 or not. If you have installed it, proceed with the process, or else install the control first.

Developer > Insert > More Controls.

Then, right−click on the sheet name and select "View Code" to open the VBA application.

Right click > View code.

Step 2

Then click on Insert, select Module, and copy the below code into the text box.

Insert > Module > Copy.

Example

Sub setQR()
    Dim xSRg As Range
    Dim xRRg As Range
    Dim xObjOLE As OLEObject
    On Error Resume Next
    Set xSRg = Application.InputBox("Please select the cell you will create QR code based on", "Create Qr Code", , , , , , 8)
    If xSRg Is Nothing Then Exit Sub
    Set xRRg = Application.InputBox("Select a cell to place the QR code", "Create Qr Code", , , , , , 8)
    If xRRg Is Nothing Then Exit Sub
    Application.ScreenUpdating = False
    Set xObjOLE = ActiveSheet.OLEObjects.Add("BARCODE.BarCodeCtrl.1")
    xObjOLE.Object.Style = 11
    xObjOLE.Object.Value = xSRg.Text
    ActiveSheet.Shapes.Item(xObjOLE.Name).Copy
    ActiveSheet.Paste xRRg
    xObjOLE.Delete
    Application.ScreenUpdating = True
End Sub

Step 3

Then close the VBA using Alt + Q. Now insert a form control button. To do so, click on developer, then on insert, select the form control button, and draw.

Alt + Q > Developer > Insert > Button > Draw.

Step 4

In the pop−up window, click on "Set QR" and click "OK”.

Setqr > Ok.

Step 5

Then exit the design mode, click on the button, select the cell containing the text, and click OK.

Design > Select cell > Ok.

Step 6

Then click on the cell to insert the Qr, and click OK to complete the task.

Select cell > Ok.

Conclusion

In this tutorial, we have used a simple example to demonstrate creating QR codes based on cell values in Excel to highlight a particular set of data.

Updated on: 19-Jul-2023

459 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements