With Microsoft Excel, you can use it for helping with your work, and in this post, I have a new function that shows you you can create a QR code or Barcode with an easy VBA code. And you can scan or print it out for your work. For this article, I will show you how to generate QR codes using Visual Basic Application code (VBA) with Google APIs. Note that your PC should be connected internet before generation because Google APIs generate QR codes for you online.

Excel Contents:

So If you want to create a function and generate QR codes in Excel, please follow with me step by step :

Create QR code using VBA code in Excel

Before you can create generator function, you should be :

1 – Open Excel

2 – Create a table for putting value and QR code picture

Adding your text at Value column for generator values

3 – Press Alt + F11 for open VBA editor

Go on the Insert tab and choose Module for module creation. And after module creation so you can coding create a generator function.

The following coding:

Function GenerateQR(qrcode_value As String)

    Dim URL As String
    Dim My_Cell As Range
    Set My_Cell = Application.Caller
    URL = "https://chart.googleapis.com/chart?chs=100x100&&cht=qr&chl=" & qrcode_value
    On Error Resume Next
      ActiveSheet.Pictures("My_QR_CODE_" & My_Cell.Address(False, False)).Delete
    On Error GoTo 0
    With Selection.ShapeRange(1)
     .Name = "My_QR_CODE_" & My_Cell.Address(False, False)
     .Left = My_Cell.Left + 5
     .Top = My_Cell.Top + 5
    End With
    GenerateQR = ""
End Function

4 – After you finish your coding, you go on the Excel Workbook and call function and press Enter


Final Result :

Note : Your PC should be connect internet, Save your Excel file as Excel Macro – Enabled Workbook (*.xlsm)