+ -
当前位置:首页 → 问答吧 → 求助 为什么 我这句话下标越界。。。。

求助 为什么 我这句话下标越界。。。。

时间:2011-08-07

来源:互联网


MsgBox newsheet.Cells.Find(what:="123", LookAt:=xlWhole).row


如果把 , LookAt:=xlWhole 去掉 就可以正常了。。。。但是我要单元格匹配啊。。。

作者: parv2   发布时间: 2011-08-07

因为没找到

If Not (newsheet.Cells.Find(what:="123", LookAt:=xlWhole) Is Nothing) Then
  MsgBox newsheet.Cells.Find(what:="123", LookAt:=xlWhole).row
End If

作者: caozhy   发布时间: 2011-08-07

引用 1 楼 caozhy 的回复:
因为没找到

If Not (newsheet.Cells.Find(what:="123", LookAt:=xlWhole) Is Nothing) Then
MsgBox newsheet.Cells.Find(what:="123", LookAt:=xlWhole).row
End If


+1

作者: z_wenqian   发布时间: 2011-08-07

不是下标越界,是没找到匹配单元格,newsheet.Cells.Find(what:="123", LookAt:=xlWhole)将返回Nothing,Nothing是没有row属性的,当然出错了。改为:
Dim r As Range
Set r = Me.Cells.Find(what:="123", LookAt:=xlWhole)
If Not r Is Nothing Then
  MsgBox r.Row
Else
  MsgBox "找不到指定单元格"
End If

作者: c_cyd2008   发布时间: 2011-08-07

热门下载

更多