接收运行时错误'':对象不支持此属性或方法
有人可以帮我调试并找出为什么我用.Find方法收到这个错误吗?
Sub TestCode()
'===============================================================================================
'Description: Loops through the selected site and adds in the vulnerability totals for each _
systems
'Originally written by: Troy Pilewski
'Date: 2016-06-30
'===============================================================================================
'Declares variables
Dim ToWorkbook, FromWorkbook As Workbook
Dim ToWorksheet, FromWorkSheet As Worksheet
Dim DataRange, WholeRange As Range
Dim FromWorkbookVarient As Variant
Dim TitleString, FilterName, CurrentSystemName As String
Dim LastRow As Long
'-----------------------------------------------------------------------------------------------
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set ToWorkbook = ActiveWorkbook
Set ToWorksheet = ToWorkbook.Worksheets("SITE")
LastRow = ToWorksheet.Range("Z:Z").Find( _
What:="*", _
After:=ToWorkbook.Range("Z1"), _
LookAt:=xlByRows, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious _
).Row
MsgBox _
Title:="Ship Range", _
Prompt:="Z1:Z" & LastRow
End Sub
答案 0 :(得分:2)
这是错误:ToWorkbook.Range("Z1")
。无法将范围设置为工作簿。
据透露...
此外,Dim x , y as String
将y设为string
,将x设为variant
。