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
| Sub regoup()
Dim regroupSheet As Worksheet
Dim sheet As Worksheet
Dim dest As Range
Application.ScreenUpdating = False
Application.DisplayAlerts = False
If SheetExists("Regroupement") Then
ThisWorkbook.Sheets("Regroupement").Delete
Set regroupSheet = ThisWorkbook.Sheets.Add(ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count - 1))
regroupSheet.Name = "Regroupement"
Set dest = regroupSheet.[A1]
End If
For Each sheet In ThisWorkbook.Sheets
If LCase(Right(sheet.Name, 5)) = "group" Then
sheet.UsedRange.Copy dest
Set dest = dest.Offset(sheet.UsedRange.Rows.Count)
End If
Next
Application.DisplayAlerts = True
Application.ScreenUpdating = False
End Sub
Function SheetExists(shtName As String) As Boolean
Dim sht As Worksheet
On Error Resume Next
Set sht = ThisWorkbook.Sheets(shtName)
On Error GoTo 0
SheetExists = Not sht Is Nothing
End Function |
Partager