Macro to group workbooks


Macro to group workbooks by the color of sheet tabs


Sub GroupSheetsByColor()
Dim x As Integer
Dim y As Integer
For x = 1 To Sheets.Count
For y = 1 To x - 1
If Sheets(y).Tab.ColorIndex = Sheets(x).Tab.ColorIndex Then
Sheets(y).Move Before:=Sheets(x)
End If
Next y
Next x
End Sub

How to use codes shared here?