Bonjour,
j'ai réussi a créer une macro qui récupère des données dans les nombreux onglets qui constituent mon fichier excel...
Etant débutante an VBA je pense que ma procédure n'est pas optimisée car je trouve qu'elle prend un peu trop de temps. Est-il possible d'accélérer le processus?
Sub compilation()
Dim sh As Worksheet
Dim Dercol As Long
Dim Lig As Long, Col As Integer
Lig = 1 'Première ligne où copier
Col = 1 'Colonne où copier
L = 2
Application.DisplayAlerts = False
Sheets("Compilation").Range("A1:FZ100").Clear
For Each sh In ActiveWorkbook.Sheets
Dim N As String
N = sh.Name
If (N <> "data") And (N <> "Indicateur") And (N <> Compilation) And (N <> Aide) Then
Sheets("Compilation").Cells(Lig, Col) = sh.Range("D1")
Sheets("Compilation").Cells(L, Col) = sh.Range("D8")
Col = Col + 2
End If
N = sh.Name
If (N <> "data") And (N <> "Indicateur") And (N <> Compilation) And (N <> Aide) Then
Dercol = ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastCell).Column
sh.Range("B12:B50").Copy Sheets("Compilation").Cells(3, Dercol)
End If
N = sh.Name
If (N <> "data") And (N <> "Indicateur") And (N <> Compilation) And (N <> Aide) Then
Dercol = ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastCell).Column
sh.Range("F12:F50").Copy Sheets("Compilation").Cells(3, Dercol + 1)
End If
Next
Sheets("Indicateur").Select
End Sub
Merci
j'ai réussi a créer une macro qui récupère des données dans les nombreux onglets qui constituent mon fichier excel...
Etant débutante an VBA je pense que ma procédure n'est pas optimisée car je trouve qu'elle prend un peu trop de temps. Est-il possible d'accélérer le processus?
Sub compilation()
Dim sh As Worksheet
Dim Dercol As Long
Dim Lig As Long, Col As Integer
Lig = 1 'Première ligne où copier
Col = 1 'Colonne où copier
L = 2
Application.DisplayAlerts = False
Sheets("Compilation").Range("A1:FZ100").Clear
For Each sh In ActiveWorkbook.Sheets
Dim N As String
N = sh.Name
If (N <> "data") And (N <> "Indicateur") And (N <> Compilation) And (N <> Aide) Then
Sheets("Compilation").Cells(Lig, Col) = sh.Range("D1")
Sheets("Compilation").Cells(L, Col) = sh.Range("D8")
Col = Col + 2
End If
N = sh.Name
If (N <> "data") And (N <> "Indicateur") And (N <> Compilation) And (N <> Aide) Then
Dercol = ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastCell).Column
sh.Range("B12:B50").Copy Sheets("Compilation").Cells(3, Dercol)
End If
N = sh.Name
If (N <> "data") And (N <> "Indicateur") And (N <> Compilation) And (N <> Aide) Then
Dercol = ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastCell).Column
sh.Range("F12:F50").Copy Sheets("Compilation").Cells(3, Dercol + 1)
End If
Next
Sheets("Indicateur").Select
End Sub
Merci