1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| Private Sub UserForm_Initialize()
Dim Nb As Byte, i As Byte
Dim Sem As Integer
Dim DteDeb As Date
Dim Tb
With Worksheets("Feuil1")
DteDeb = .Range("B1")
Nb = Val(.Range("B2"))
If Nb > 1 Then
Tb = .Range("A4").Resize(Nb, 1).Value
Sem = DateDiff("ww", DteDeb, Date, vbMonday)
Organise Tb, Sem
For i = 1 To Nb
Me.Controls("Label" & i).Caption = Tb(i, 1)
Next i
Else
Me.Label1.Caption = .Range("A4")
End If
End With
End Sub
Private Sub Organise(ByRef Tb, ByVal S As Integer)
Dim Nb As Byte, i As Byte
Dim Str As String
Dim T As Integer
Dim Tmp, Tablo
Nb = UBound(Tb, 1)
ReDim Tmp(1 To Nb)
T = S Mod Nb
If T > 0 Then
For i = 1 To Nb
Tmp(i) = IIf(i = T + 1, "@", "") & Tb(i, 1)
Next i
Str = Join(Tmp, "|")
Tablo = Split(Str, "|@")
Str = Tablo(1) & "|" & Tablo(0)
Tablo = Split(Str, "|")
For i = 1 To Nb
Tb(i, 1) = Tablo(i - 1)
Next i
End If
End Sub |
Partager