views:

77

answers:

1

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

Thanks

+2  A: 

you can use CoCreateGuid API function

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
Svetlozar Angelov
Thank You for your answer. This is perfect.
codingguy3000