The following demonstrates how to use VBA Excel macro language to download random data from SwiftRNG device when used with 32 bit Microsoft Excel. Before using the following examples, make sure the SwiftRNG device is plugged into one of USB ports available. A thread-safe and process-safe 32 bit SwiftRNG.dll should be used for the example to work.

A sample source code that retrieves a random VBA Integer from SwiftRNG device and insterts that value into A1 cell of the Excel Sheet

' Include the exact path to the SwiftRNG.dll (it uses additional dependencies from same location) available with the software kit.
Declare Function getRandomByte Lib "C:\tools\windows-x86\Release\SwiftRNG.dll" _
        Alias "swftGetEntropyByteSynchronized" () As Integer
        
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
    ByRef Destination As Any, _
    ByRef Source As Any, _
    ByVal Length As Long)
    
    Private Function getRandomInteger() As Integer
        Dim RandomBytes(1 To 2) As Byte
        Dim i As Integer
        Dim rndInteger As Integer
        Dim rndByte As Integer
        
        For i = 1 To LenB(rndInteger)
            rndByte = getRandomByte()
            If rndByte > 255 Then
                Err.Raise Number:=1, Description:="Could not retrieve random Integer from SwiftRNG device"
            Else
                RandomBytes(i) = rndByte
            End If
        Next

        CopyMemory rndInteger, RandomBytes(1), LenB(rndInteger)
        getRandomInteger = rndInteger
    End Function

Sub Macro1()
    Dim rndInteger As Integer
    rndInteger = getRandomInteger()
    [A1].Value = rndInteger
End Sub

A sample source code that retrieves a random VBA Double from SwiftRNG device and insterts that value into A1 cell of the Excel Sheet

' Include the exact path to the 32 bit version of the SwiftRNG.dll available with the software kit
Declare Function getRandomByte Lib "C:\tools\windows-x86\Release\SwiftRNG.dll" _
        Alias "swftGetEntropyByteSynchronized" () As Integer
        
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
    ByRef Destination As Any, _
    ByRef Source As Any, _
    ByVal Length As Long)
    
    Private Function getRandomDouble() As Double
        Dim RandomBytes(1 To 8) As Byte
        Dim i As Integer
        Dim d As Double
        Dim rndByte As Integer
        
        For i = 1 To 8
            rndByte = getRandomByte()
            If rndByte > 255 Then
                Err.Raise Number:=1, Description:="Could not retrieve random double from SwiftRNG device"
            Else
                RandomBytes(i) = rndByte
            End If
        Next

        CopyMemory d, RandomBytes(1), LenB(d)
        getRandomDouble = d
    End Function

Sub Macro1()
    Dim randomDouble As Double
    randomDouble = getRandomDouble()
    [A1].Value = randomDouble
End Sub