Hello Yllew,
Try modifying your code as follows:-
Sub Group_Sheets()
Dim sht As Worksheet, ws As Worksheet
Dim shRng As Range, lr As Long
Set sht = Sheets("List")
lr = sht.Range("A" & Rows.Count).End(xlUp).Row
Set shRng = sht.Range("A1:A" & lr)
Application.ScreenUpdating = False
For Each ws In Worksheets
If shRng.Find(What:=ws.Name, LookAt:=xlWhole) Is Nothing Then '----> This line will exclude the unrequired sheets.
ws.Columns("D:F").Group
ws.Columns("O:Q").Group
ws.Columns("Z:AB").Group
End If
Next ws
Application.ScreenUpdating = True
End Sub
Firstly, create a new sheet and name it List. Next, starting in cell A1 of the List sheet, list all the sheets that you wish to exclude from the whole process (sheets 11 - 15).
The code should now only group the sheets that are not listed in the List sheet. You can add or remove sheets from the list as your needs may require in future.
I hope that this helps.
Cheerio,
vcoolio.
Bookmarks