Sub DeleteUnusedMasterLayouts()
Dim oDesign As Design
Dim oMaster As Master
Dim oCustomLayout As CustomLayout
Dim i As Long
Dim isUsed As Boolean
'Loop through each design in the presentation
For Each oDesign In ActivePresentation.Designs
Set oMaster = oDesign.SlideMaster
'Loop backward through custom layouts to avoid indexing issues when deleting
For i = oMaster.CustomLayouts.Count To 1 Step -1
Set oCustomLayout = oMaster.CustomLayouts(i)
isUsed = False
'Check if the custom layout is used by any slide
For Each oSlide In ActivePresentation.Slides
If oSlide.Layout = oCustomLayout Then
isUsed = True
Exit For
End If
Next oSlide
'Delete if not used
If Not isUsed Then
oCustomLayout.Delete
End If
Next i
Next oDesign
End Sub