Reputation: 3
I have a line of code that is displaying the application defined or object defined error, I have no idea why.
filenm17 = "DSR Consolidated"
findstring16 = "21"
filenm17 and findstring16 are both defined as strings. I tried removing findstring16 and replacing it with the formula to get findstring16 (it's a cell reference .value) but that still didn't work.
Workbooks(filenm17).Sheets("5").Range(Cells(67, findstring16 + 2), _
Cells(440, findstring16 + 2)) = firstarray
Please help!
Upvotes: 0
Views: 110
Reputation: 166306
Without a qualifying worksheet, your Cells()
will refer to the Activesheet: if that isn't "5" then they don't match the Range()
and that will trigger the error you're getting.
Try:
With Workbooks(filenm17).Sheets("5")
.Range(.Cells(67, CLng(findstring16) + 2), _
.Cells(440, CLng(findstring16) + 2)).Value = firstarray
End With
Upvotes: 2