'Déclaration de la fonction pour le masquage du bouton de fermeture sur l'UserForm
'----------------------------------------------------------------------------------
Option Explicit
Private Declare Function GetWindowLongA Lib "user32" _
(ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLongA Lib "user32" _
(ByVal hWnd As Long, ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Private Declare Function FindWindowA Lib "user32" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
'Variable qui va nous servir à Masquer le bouton de fermeture.
Dim hWnd As Long
'Macro qui rapporte la liste des dates et les transpose dans le ComboBox "Par_Date"
Private Sub UserForm_Initialize()
'Raffraichir pendant le code
Application.ScreenUpdating = True
'Masquer le bouton de fermeture dès l'ouverture de l'UserForm
hWnd = FindWindowA("Thunder" & IIf(Application.Version Like "8*", _
"X", "D") & "Frame", Me.Caption)
SetWindowLongA hWnd, -16, GetWindowLongA(hWnd, -16) And &HFFF7FFFF
'Curseur sur le ComboBox "Par_Date"
ComboBox1.SetFocus
'Transposer les dates dans le Combobox et faire le tri
Set f = Sheets("feuil2")
Set mondico = CreateObject("Scripting.Dictionary")
a = f.Range("e3:e" & f.[e65000].End(xlUp).Row).SpecialCells(xlCellTypeVisible) ' tableau a(n,1) pour rapidité
For i = LBound(a) To UBound(a)
If a(i, 1) <> "" Then mondico(a(i, 1)) = ""
Next i
temp = mondico.keys
Tri temp, LBound(temp), UBound(temp)
Me.ComboBox1.List = temp
End Sub
Sub Tri(a, gauc, droi) ' Quick sort
ref = a((gauc + droi) \ 2)
g = gauc: d = droi
Do
Do While a(g) < ref: g = g + 1: Loop
Do While ref < a(d): d = d - 1: Loop
If g <= d Then
temp = a(g): a(g) = a(d): a(d) = temp
g = g + 1: d = d - 1
End If
Loop While g <= d
If g < droi Then Call Tri(a, g, droi)
If gauc < d Then Call Tri(a, gauc, d)
End Sub
Private Sub CommandButton1_Click()
Unload UserForm1
End Sub