'### Nécessite les références suivantes ###
'Library MSForms
' C:\WINDOWS\system32\FM20.DLL
' Microsoft Forms 2.0 Object Library
'
'Library MSComctlLib
' C:\WINDOWS\system32\MSCOMCTL.OCX
' Contrôles communs Microsoft Windows 6.0
'##########################################
Private Sub UserForm_Initialize()
Dim WB As Workbook
Dim WS As Worksheet
Dim R As Range
Dim PGE As MSForms.Page
Dim LV As MSComctlLib.ListView
Dim cpt&
Dim var
Dim i&
Dim j&
Dim MP As MSForms.MultiPage
With Me
.Width = 600
.Height = 400
End With
Set MP = Me.Controls.Add("forms.Multipage.1")
With MP
.Left = 0
.Top = 0
.Width = Me.Width
.Height = Me.Height - 100 '- 100 pour laisser de la place pour les boutons éventuels
End With
MP.Pages.Clear
For Each WB In Application.Workbooks
For Each WS In WB.Worksheets
Set R = WS.UsedRange
If R.Cells.Count > 1 Then 'si la feuille ne comporte qu'une cellule on ne fait pas le traitement
var = R
cpt& = cpt& + 1
Set PGE = MP.Pages.Add
PGE.Caption = WS.Name
Set LV = PGE.Controls.Add("MsComCtlLib.ListViewCtrl.2", "ListView" & cpt&)
With LV
.Name = "monListView" & cpt&
.Left = 0
.Top = 0
.Width = MP.Width - 12
.Height = MP.Height - 12
.View = lvwReport
For i& = 1 To UBound(var, 2)
.ColumnHeaders.Add Text:=var(1, i&), Width:=80
Next i&
With .ListItems
For i& = 2 To UBound(var, 1)
.Add Text:=var(i&, 1)
Next i&
End With
For j& = 2 To UBound(var, 2)
For i& = 2 To UBound(var, 1)
.ListItems(i& - 1).ListSubItems.Add Text:=var(i&, j&)
Next i&
Next j&
End With
End If
Next WS
Next WB
End Sub