xlFormulas2在professional plus 2016版为空导致下标超出范围异常
xlFormulas2 is empty in professional plus 2016 edition causing subscript out of range exception
我有 2 个环境,一个是 MS office 365 企业应用程序,另一个是 professional plus 2016。
宏代码在 MS office 365 企业版应用程序中运行良好,但在 Selection.Find 功能的 professional plus 2016 中面临 'subscript out of range' 异常。
虽然调试时注意到 xlFormulas2 为空,这可能会导致错误,但不确定为什么 xlFormulas2 在 professional plus 2016 中为空,但在其他环境中工作正常的 -4185。
Sub AA_01_Spring_China_Individual()
sNumber = InputBox("Which week you would like to update?", "Week No:")
sResponse = "Week " & sNumber
Sheets("BD Calls").Select
Columns("A:A").Select
Selection.Find(What:="Beijing", After:=ActiveCell, LookIn:=xlFormulas2, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
可能 xlFormulas2
适用于 Office 365。要使查找在这两种情况下都有效,您可以避免类似...
的错误
Sub Macro1()
Dim foundCl As Range
On Error Resume Next
Set foundCl = Selection.Find(What:="Beijing", After:=ActiveCell, LookIn:=xlFormulas2, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False)
If foundCl Is Nothing Then
Set foundCl = Selection.Find(What:="Beijing", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
End If
On Error GoTo 0
Debug.Print foundCl.Address
foundCl.Activate
End Sub
我有 2 个环境,一个是 MS office 365 企业应用程序,另一个是 professional plus 2016。 宏代码在 MS office 365 企业版应用程序中运行良好,但在 Selection.Find 功能的 professional plus 2016 中面临 'subscript out of range' 异常。
虽然调试时注意到 xlFormulas2 为空,这可能会导致错误,但不确定为什么 xlFormulas2 在 professional plus 2016 中为空,但在其他环境中工作正常的 -4185。
Sub AA_01_Spring_China_Individual()
sNumber = InputBox("Which week you would like to update?", "Week No:")
sResponse = "Week " & sNumber
Sheets("BD Calls").Select
Columns("A:A").Select
Selection.Find(What:="Beijing", After:=ActiveCell, LookIn:=xlFormulas2, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
可能 xlFormulas2
适用于 Office 365。要使查找在这两种情况下都有效,您可以避免类似...
Sub Macro1()
Dim foundCl As Range
On Error Resume Next
Set foundCl = Selection.Find(What:="Beijing", After:=ActiveCell, LookIn:=xlFormulas2, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False)
If foundCl Is Nothing Then
Set foundCl = Selection.Find(What:="Beijing", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
End If
On Error GoTo 0
Debug.Print foundCl.Address
foundCl.Activate
End Sub