Create A GUID
Private Declare Function CoCreateGuid Lib "ole32" (Id As Any) As Long
Function CreateGUID() As String
Dim btID(0 To 15) As Byte
Dim i As Long
If CoCreateGuid(btID(0)) = 0 Then
For i = 0 To 15
CreateGUID = CreateGUID + IIf(btID(i) < 16, "0", "") + Hex$(btID(i))
Next i
CreateGUID = Left$(CreateGUID, 8) & "-" & _
Mid$(CreateGUID, 9, 4) & "-" & _
Mid$(CreateGUID, 13, 4) & "-" & _
Mid$(CreateGUID, 17, 4) & "-" & _
Right$(CreateGUID, 12)
Else
MsgBox "Error while creating GUID!"
End If
End Function
Sub test()
Cells(1) = CreateGUID()
End Sub
RBS
"Derek Hart" wrote in message
...
I wish to create a GUID in a cell. I could put it on a macro button on the
toolbar. Does Excel have anything built in to do this, or do I need VBA
code. I would appreciate a sample.
Derek
|