Ваш отступ неверен. В Python отступы сигнализируют об окончании блока кода
import openpyxl, glob
# This loops through all of the workbooks
for file in glob.glob('*.xlsx'):
wb = openpyxl.load_workbook(file)
# Now, once all of the workbooks have been looped through, only the last one is edited
for sheetName in wb.worksheets:
if sheetName.title != 'abc':
wb.remove(sheetName)
wb.save(file)
Попробуйте это
import openpyxl, glob
for file in glob.glob('*.xlsx'):
wb = openpyxl.load_workbook(file)
for sheetName in wb.worksheets:
if sheetName.title != 'abc':
wb.remove(sheetName)
wb.save(file)