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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
| Function TabStripAddTabs(oTabStrip As MSForms.TabStrip, _
Captions As Variant, _
Optional MultiLine As Boolean = True, _
Optional Orientation As fmTabOrientation)
' Philippe Tulliez (https://magicoffice.be)
' Arguments
' oTabStrip l'Objet TabStrip
' Captions Array (1 dimension) contenant les noms à passer à la propriété Caption des Tab
' [MultiLine] Si True (défaut), affiche les onglets sur plusieurs lignes si elle ne peuvent pas être affichée sur une seule
' [Orientation] Orientation des Tabs (fmTabOrientationBottom, ..Left, ..Right, ..Top)
'
' Déclaration et affectation
Dim e As Byte
With oTabStrip
.Tabs.Clear ' Efface tous les onglets
.TabOrientation = Orientation ' Orientation des onglets (Tabs)
.MultiRow = MultiLine ' Défini la propriété MultiLine
For e = LBound(Captions) To UBound(Captions)
.Tabs.Add bstrCaption:=Captions(e)
Next
End With
End Function
Option Explicit 'oblige à déclarer toutes les variable
Private i As Integer 'déclare la variable I (Incréments)
Private Sub FiltreAxe_Change()
Dim t As Variant
For i = 0 To Cells(Rows.Count, 1).End(xlUp).Row - 1
t = Array(Sheets("GestionProjet").Cells(i + 1, 4).Value)
With GestionProjet
TabStripAddTabs oTabStrip:=.tabDynamic, Captions:=t
.Show
End With
Axestrat = Sheets("Liste projet").Cells(i + 1, 2).Value
Thème = Sheets("Liste projet").Cells(i + 1, 3).Value
NomRéduit = Sheets("Liste projet").Cells(i + 1, 5).Value
Réferent = Sheets("Liste projet").Cells(i + 1, 6).Value
Datedébutprojet = Sheets("Liste projet").Cells(i + 1, 9).Value
Datefinprojet = Sheets("Liste projet").Cells(i + 1, 10).Value
End If
Next i
End Sub
Private Sub TabStrip1_Change()
If FiltreAxe = "" Then
Dim i As Integer
For i = 0 To TabStrip1.Tabs.Count - 1
Select Case TabStrip1.Value
Case i
Axestrat = Sheets("Liste projet").Cells(i + 1, 2).Value
Thème = Sheets("Liste projet").Cells(i + 1, 3).Value
NomRéduit = Sheets("Liste projet").Cells(i + 1, 5).Value
Réferent = Sheets("Liste projet").Cells(i + 1, 6).Value
Datedébutprojet = Sheets("Liste projet").Cells(i + 1, 9).Value
Datefinprojet = Sheets("Liste projet").Cells(i + 1, 10).Value
End Select
Next i
End If
If FiltreAxe <> "" Then
For i = 0 To TabStrip1.Tabs.Count - 1
Select Case TabStrip1.Value
Case i
If Sheets("Liste projet").Cells(i + 1, 2).Value = FiltreAxe Then Axestrat = Sheets("Liste projet").Cells(i + 1, 2).Value
If Sheets("Liste projet").Cells(i + 1, 2).Value = FiltreAxe Then Thème = Sheets("Liste projet").Cells(i + 1, 3).Value
If Sheets("Liste projet").Cells(i + 1, 2).Value = FiltreAxe Then NomRéduit = Sheets("Liste projet").Cells(i + 1, 5).Value
If Sheets("Liste projet").Cells(i + 1, 2).Value = FiltreAxe Then Réferent = Sheets("Liste projet").Cells(i + 1, 6).Value
If Sheets("Liste projet").Cells(i + 1, 2).Value = FiltreAxe Then Datedébutprojet = Sheets("Liste projet").Cells(i + 1, 9).Value
If Sheets("Liste projet").Cells(i + 1, 2).Value = FiltreAxe Then Datefinprojet = Sheets("Liste projet").Cells(i + 1, 10).Value
End Select
Next i
End If
End Sub
Private Sub UserForm_Initialize()
With Sheets("liste")
FiltreAxe.List = .Range("A1:S4").Value
FiltreRéférent.List = .Range("B1:B10").Value
End With
Me.Left = Application.Left + Application.Width / 2 - Me.Width / 2
Me.top = Application.top + Application.Height / 2 - Me.Height / 2
For i = 0 To Cells(Rows.Count, 1).End(xlUp).Row - 1 'boucle 1 = boucle sur tous les projets de la liste
With GestionProjet.TabStrip1
.Tabs.Add
.Tabs(i).Caption = Sheets("Liste projet").Cells(i + 1, 4).Value
End With
Next i
TabStrip1.Tabs(0).Visible = False
TabStrip1.Tabs(1).Visible = False
TabStrip1.Tabs(2).Visible = False
TabStrip1.Tabs(3).Visible = False
TabStrip1.Tabs(4).Visible = False
End Sub |