设置范围variables时应用程序定义或对象定义的错误
我有一个Range
variables和一个单独的工作簿,我尝试填充值。 我使用TheRange
,首先将其设置为clientsColl.Count
行和1000列的范围。
Dim TheRange As Range With resultWorkbook.Worksheets("matrix_random") Set TheRange = _ .Range(Cells(2, 2), Cells(clientsColl.Count, _ 1000))) ... End With
但是,我不断收到这个错误,不知道为什么..
应用程序定义或对象定义的错误
只是为了将来的用户得到答案。
您需要With resultWorkbook.Worksheets("matrix_random")
语句来限定您的.Cells
。
另外,第二个Cells
有交换Rows
和Columns
。
码
Dim TheRange As Range With resultWorkbook.Worksheets("matrix_random") Set TheRange = .Range(.Cells(2, 2), .Cells(1000, clientsColl.Count)) '<-- you have 1 "extra" closing bracket End With