Need help with VBA-generated QR Code

YansaneYansane

New Member
Joined
Nov 1, 2024
Messages
34
Office Version
  1. 2019
Platform
  1. Windows
  2. Web
Hi Tech,

Need help with VBA-generated QR Code based on values in certain cells.........................
Series, Firstname, Lastname, Math Grade, Stat Grade, English Grade, Email, Tel, Notification.

Thank you
 

Attachments

  • Excel help.jpg
    Excel help.jpg
    218.5 KB · Views: 17

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
QR codes require URL links. I don't see any in your picture.
 
Upvote 0
I'm guessing you wan't to store the info under a QR code. It's typically used for a URL. Here's a sample VBA function. It stores the info separated by the pipe "|" symbol.
VBA Code:
Function GETQRCODES(QrCodeValues As String)
    Dim URL As String
    Dim CellValues As Range
    Set CellValues = Application.Caller
    
    URL = "https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=" & QrCodeValues
    On Error Resume Next
    ActiveSheet.Pictures("Generated_QR_CODES_" & CellValues.Address(False, False)).Delete
    
    On Error GoTo 0
    ActiveSheet.Pictures.Insert(URL).Select
    With Selection.ShapeRange(1)
        .Name = "Generated_QR_CODES_" & CellValues.Address(False, False)
        .Left = CellValues.Left + 2
        .Top = CellValues.Top + 2
    End With
    
    GETQRCODES = ""
End Function

Usage:
Excel Formula:
=GETQRCODES(TEXTJOIN("|",,B2:I2))

Screen Shot 2024-12-15 at 10.35.54 PM.png
 
Upvote 0
Solution
I'm guessing you wan't to store the info under a QR code. It's typically used for a URL. Here's a sample VBA function. It stores the info separated by the pipe "|" symbol.
VBA Code:
Function GETQRCODES(QrCodeValues As String)
    Dim URL As String
    Dim CellValues As Range
    Set CellValues = Application.Caller
   
    URL = "https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=" & QrCodeValues
    On Error Resume Next
    ActiveSheet.Pictures("Generated_QR_CODES_" & CellValues.Address(False, False)).Delete
   
    On Error GoTo 0
    ActiveSheet.Pictures.Insert(URL).Select
    With Selection.ShapeRange(1)
        .Name = "Generated_QR_CODES_" & CellValues.Address(False, False)
        .Left = CellValues.Left + 2
        .Top = CellValues.Top + 2
    End With
   
    GETQRCODES = ""
End Function

Usage:
Excel Formula:
=GETQRCODES(TEXTJOIN("|",,B2:I2))

View attachment 120365
Hi Cubist,

Is it possible to have a sub which can be invoked?

The code is working but placing the QR Code outside the cell around the row.......

Thanks.
 
Upvote 0
To invoke it automatically, it'd need to know where is the last row in your data set. Your sample data seems to have a lot of missing data. What would be the best indicator for the last row?
 
Upvote 0
Hello Cubist,

It's working fine now..
The way you set it up is more intuitive... It populates the QR Code as soon as there's new record in the row. ....and the GetQRCodes formula is present in the column.

However, the formula needs to be copied down, "each time", for it to be taken into account. 👀:unsure:


Thanks a million
 

Attachments

  • Get QR Code.jpg
    Get QR Code.jpg
    8.7 KB · Views: 9
Upvote 0

Forum statistics

Threads
1,225,619
Messages
6,186,045
Members
453,335
Latest member
sfd039

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top