VBA Excel结束如果没有块如果错误

在我的代码中,我有一些简单的问题。 情况是这样的:我正在用ExcelForm在excel的基础上select几个月,数据从我的报告从另一个报告。 要分析某个月份的数据,我们需要以前一个月的数据。 所以对于一月份,我们需要去年12月份的数据。 我做了一个特殊的分支,以防万一需要分析一月份的数据,我们也需要旧的数据库。 并用这个说法我有一个问题,我得到的错误“VBA结束如果没有块如果错误”:

'If the month that was selected is January then we need to open old Visual file Month If MonthName = Lists.Range("A2").Value Then 'it means January Call January Else For Each ws In Worksheets If ws.Name = "December" Then Sheets("December").Delete End End If Next ws End If 

请,有人可以帮忙吗?

使用退出For退出For循环。

 If MonthName = Lists.Range("A2").Value Then 'it means January Call January Else For Each ws In Worksheets If ws.Name = "December" Then ws.Delete Exit For End If Next ws End If