How to create a GUID in Excel ?

How to create a GUID in Excel ?

Asked on January 11, 2019 in

The below function in v.2013 excel vba macro code, to create a GUID in Excel :

```Public Function GetGUID() As String
GetGUID = Mid\$(CreateObject("Scriptlet.TypeLib").GUID, 2, 36)
End Function
```
Answered on January 11, 2019.

Use this following solution :

The latest version of Excel, there is the syntax along commas, but not semicolons.

```=CONCATENATE(DEC2HEX(RANDBETWEEN(0,4294967295),8),"-",DEC2HEX(RANDBETWEEN(0,42949),4),"-",DEC2HEX(RANDBETWEEN(0,42949),4),"-",DEC2HEX(RANDBETWEEN(0,42949),4),"-",DEC2HEX(RANDBETWEEN(0,4294967295),8),DEC2HEX(RANDBETWEEN(0,42949),4))
```

Otherwise we can go for lower-cased according to this.

```=LOWER(CONCATENATE(DEC2HEX(RANDBETWEEN(0,4294967295),8),"-",DEC2HEX(RANDBETWEEN(0,42949),4),"-",DEC2HEX(RANDBETWEEN(0,42949),4),"-",DEC2HEX(RANDBETWEEN(0,42949),4),"-",DEC2HEX(RANDBETWEEN(0,4294967295),8),DEC2HEX(RANDBETWEEN(0,42949),4)))
```
Answered on January 11, 2019.

Try this alternative solution :

```=CONCATENATE(
DEC2HEX(RANDBETWEEN(0;4294967295);8);"-";
DEC2HEX(RANDBETWEEN(0;42949);4);"-";
DEC2HEX(RANDBETWEEN(0;42949);4);"-";
DEC2HEX(RANDBETWEEN(0;42949);4);"-";
DEC2HEX(RANDBETWEEN(0;4294967295);8);
DEC2HEX(RANDBETWEEN(0;42949);4)
)
```
Answered on January 11, 2019.

By using the following function in v.2013 excel vba macro code

Public Function GetGUID() As String
GetGUID = Mid\$(CreateObject(“Scriptlet.TypeLib”).GUID, 2, 36)
End Function

Answered on February 5, 2019.