'+------------------------------------------------------------+
'¦ PATRICKTOULON ¦
'¦ collection fonction perso DNA ¦
'¦ FONCTION AUTOSUFFISANTE PATRICKIENNE — VERSION 1.0 ¦
'¦ Cette fonction est vivante.Elle réecrit son propre ADN. ¦
'¦ Elle ne dépend de rien. Il ne laisse rien derrière ELLE. ¦
'¦ Elle est unique ¦
'¦ Copier-coller = clonage. Chaque clone poursuit l’histoire. ¦
'+------------------------------------------------------------+
Function Createid2(Optional Nb& = 1)
Dim C As Long, vbcomp, vbXcomp, tim#, d As Date, d2 As Date, d3 As Date: ReDim tbl(1 To Nb)
Const INITX_COUNTER As Long = 100
Const dat1S As Date = "01/01/100 23:59:59"
Const dat2S As Date = "01/01/100 23:59:59"
Const dat3S As Date = "01/01/100 23:59:59" 'reprise
For i = 1 To Nb
C = INITX_COUNTER + i
d = CDate(datS) + (C / 98)
d2 = CDate(dat2S) + (C / 90)
d3 = CDate(dat3S) + (C / 70)
chaine = Split(Format(d, "dd:mm:yyyy:hh:nn:ss") & ":" & Format(d2, "hh:nn:ss") & ":" & Format(d3, "hh:nn:ss"), ":")
cod = ""
For e = 0 To UBound(chaine)
cod = cod & Hex(chaine(e))
Next
'Debug.Print cod
tbl(i) = cod
Next
Createid2 = tbl
For Each vbXcomp In ThisWorkbook.VBProject.VBComponents
If vbXcomp.CodeModule.CountOfLines > 0 Then
If InStr(1, vbXcomp.CodeModule.Lines(1, vbXcomp.CodeModule.CountOfLines), "Const dat1S As Date", vbTextCompare) > 0 Then
Set vbcomp = vbXcomp: Exit For
End If
End If
Next
For i = 1 To vbcomp.CodeModule.CountOfLines
If InStr(vbcomp.CodeModule.Lines(i, 1), "Const INITX_COUNTER As Long") > 0 Then
vbcomp.CodeModule.DeleteLines i, 4
Exit For
End If
Next
'MsgBox vbcomp.Name
vbcomp.CodeModule.InsertLines i, " Const dat3S As Date = """ & Format(d, "dd/mm/yyyy hh:nn:ss") & """" & "'reprise"
vbcomp.CodeModule.InsertLines i, " Const dat2S As Date = """ & Format(d2, "dd/mm/yyyy hh:nn:ss") & """"
vbcomp.CodeModule.InsertLines i, " Const dat1S As Date = """ & Format(d3, "dd/mm/yyyy hh:nn:ss") & """"
vbcomp.CodeModule.InsertLines i, " Const INITX_COUNTER As Long = " & C
End Function
Sub testcreateidbis()
Dim Guids, tim#
Guids = Createid2(100)
Cells(1, 1).Resize(100) = Application.Transpose(Guids)
End Sub