如何解决运行时错误'9' [英] How to resolve Run-time error '9'
本文介绍了如何解决运行时错误'9'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
下面的代码会生成一封电子邮件。在Win7 / 2010Office下运行时显示运行时错误'9'
Hi, below code generates an email. While runing under Win7/2010Office it is showing Run-time error '9'
Private Sub CreateEmails_Click()
Call PrepareEmail
End Sub
Public Sub PrepareEmail()
Dim sheetcount As Integer
Dim managerEmail As String
sheetcount = Worksheets.Count
For i = 1 To 30
If Worksheets.Count < 4 Then
Exit For
Else
If Worksheets(sheetcount).Name = "T" Then
sheetcount = sheetcount - 1
ElseIf Worksheets(sheetcount).Name = "Template" Then
sheetcount = sheetcount - 1
ElseIf Worksheets(sheetcount).Name = "Main" Then
sheetcount = sheetcount - 1
ElseIf Worksheets(sheetcount).Name = "Exceptions" Then
sheetcount = sheetcount - 1
Else
Call SendManagerEmail(sheetcount)
Application.DisplayAlerts = False
Sheets(sheetcount).Delete
Application.DisplayAlerts = True
sheetcount = sheetcount - 1
End If
End If
Next i
推荐答案
有可能我的理由:
1)溢出 [ ^ ]
和
2)下标超出范围(错误9) [ ^ ]
点击链接,了解如何解决此错误。使用调试器并逐步检查代码(使用F8键)。
There are possible two reasons:
1) Overflow[^]
and
2) Subscript out of range (Error 9)[^]
Follow the links to find out how to fix this error. Use debugger and check the code step by step (using F8 key).
这篇关于如何解决运行时错误'9'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文