Is there any way to generate unique ID (in SQL Server newid ()) in Excel 2007

Can you create a unique identifier in Excel 2007. I am looking for the same value generated by the SQL Server newid () function.



source to share

1 answer

you can use CoCreateGuid

Declare Function CoCreateGuid Lib "ole32" (ByRef GUID As Byte) As Long

Public Function CreateGUID()
   Dim ID(0 To 15) As Byte
   Dim N As Long
   Dim GUID As String
   Dim Res As Long
   Res = CoCreateGuid(ID(0))
   For N = 0 To 15
      GUID = GUID & IIf(ID(N) < 16, "0", "") & Hex$(ID(N))
   Next N
   CreateGUID = GUID
End Function




All Articles