2015-12-08 34 views
0

Excel中不断想出一个错误信息说: 编译错误我应该使用哪个版本的null?

无效使用对象的

If range("C13:17").Find(11) = Nothing Then 
       'Do nothing 
      Else 
       range(findeleven).Select 
       ActiveCell.FormulaR1C1 = 1 
      End If 

请帮忙:-)

BTW它是用VBA编写

+7

尝试'是Nothing' - 不是'= Nothing' – WhiteHat

+0

您可以通过使用否定了一下缩短你的代码:'如果没有范围( “C13:17”),查找(11)没有什么然后'然后你的代码。 –

+0

“C13:17”应该是“C13:C17” –

回答

1

希望这将帮助你:)

Sub Search() 
 
Range("C13:C17").Select 
 
With Selection 
 
Set c = .Find(11, LookIn:=xlValues) 
 
If Not c Is Nothing Then 
 
       
 
      Else 
 
       Range("Your range").Select 
 
       ActiveCell.FormulaR1C1 = 1 
 
      End If 
 
End With 
 
End Sub

相关问题