Bonjour
Dans un classeur (avec une base de données de 34 colonnes et 260 lignes), le UserForm (avec une ListView de 2 colonnes) met plus de 40 secondes pour s’afficher. Est-ce normal et peut-on parer à cette lenteur ?
Merci de votre aide, Kim.
Dans un classeur (avec une base de données de 34 colonnes et 260 lignes), le UserForm (avec une ListView de 2 colonnes) met plus de 40 secondes pour s’afficher. Est-ce normal et peut-on parer à cette lenteur ?
Merci de votre aide, Kim.
PHP:
Private Sub UserForm_Initialize()
Dim i As Long, sNom As String
Sheets("BD").AutoFilterMode = False
With ListView1
With .ColumnHeaders
.Clear
.Add , , "Service", 230
.Add , , "Nbre salaries par service", 80
End With
.View = lvwReport
.FullRowSelect = True
.Gridlines = True
Application.ScreenUpdating = False
Sheets("BD").Select
i = Sheets("BD").Range("A65536").End(xlUp).Row
Sheets("BD").Range("A1:AH" & i).Select
Selection.Sort Key1:=Range("B1"), Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Sheets("BD").Cells(1, 1).Select
sNom = ""
For i = 2 To Sheets("BD").Range("B65536").End(xlUp).Row
If Sheets("BD").Cells(i, 2) <> sNom Then
.ListItems.Add , , Sheets("BD").Cells(i, 2)
.ListItems(.ListItems.Count).ListSubItems.Add , , Sheets("BD").Cells(i, 15)
sNom = Sheets("BD").Cells(i, 2)
End If
Next
ListView1.ListItems(1).Selected = False
Set ListView1.SelectedItem = Nothing
End With
Sheets("Accueil").Select
Application.ScreenUpdating = True
End Sub
Private Sub ListView1_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
Application.ScreenUpdating = False
ListView1.Sorted = False
ListView1.SortKey = ColumnHeader.Index - 1
If ListView1.SortOrder = lvwAscending Then
ListView1.SortOrder = lvwDescending
Else
ListView1.SortOrder = lvwAscending
End If
ListView1.Sorted = True
Application.ScreenUpdating = True
End Sub
Private Sub ImprimeLstVw1_Click()
Application.ScreenUpdating = False
Dim Ligne As Integer, Colonne As Integer
ActiveWorkbook.Sheets.Add
With ActiveSheet
For Ligne = 1 To ListView1.ListItems.Count
.Cells(Ligne, 1) = ListView1.ListItems(Ligne).Text
For Colonne = 1 To ListView1.ColumnHeaders.Count - 1
.Cells(Ligne, Colonne + 1) = ListView1.ListItems(Ligne).ListSubItems(Colonne).Text
Next Colonne
Next Ligne
.PrintOut
Application.DisplayAlerts = False
.Delete
Application.DisplayAlerts = True
End With
Application.ScreenUpdating = True
End Sub
Private Sub Fermer_Click()
Application.ScreenUpdating = False
Unload Me: Sheets(1).Activate
Application.ScreenUpdating = True
End Sub