Run-time error '1004' VBA

mrtom25

New Member
Joined
Aug 29, 2014
Messages
2
Hi,

I am getting a "Run-time error '1004' Application-defined of object-defined" error when running this, and was wondering if you could help.

The part of the code that gets highlighted upon debugging is this:

"Worksheets(i).Range(Cells(FindRowNumber, 1), Cells(FindRowNumber + 16, 2)).Copy"

and this is the code surrounding that:

"J = ThisWorkbook.Worksheets.Count

For i = 6 To J - 3

Dim Worksheet_name As String
Dim FindRow As Range
Dim FindRowNumber As Integer

Worksheet_name = Worksheets(i).Name

With Sheets(i).Range("A1:A1000")
Set FindRow = .Find(What:="PAYMENT SCHEDULE", LookIn:=xlValues)
End With

If Not FindRow Is Nothing Then
FindRowNumber = FindRow.Row


Worksheets(i).Range(Cells(FindRowNumber, 1), Cells(FindRowNumber + 16, 2)).Copy"

Let me know if you have any questions. I hope someone can help :)

Thank you kindly,

Tom.
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Try fully qualifying the range

Code:
Worksheets(i).Range(Worksheets(i).Cells(FindRowNumber, 1), Worksheets(i).Cells(FindRowNumber + 16, 2)).Copy
 
Upvote 0
Hi

Peter already corrected you statement: When you specify a range all the range objects must be in the same worksheet.


This would be an alternative way to do the copy:

Code:
Worksheets(i).Rows(FindRowNumber).Resize(17, 2).Copy
 
Upvote 0
Thank you very much both. I knew it would be something straightforward.

Kindest Regards,

Tom.
 
Upvote 0

Forum statistics

Threads
1,207,168
Messages
6,076,907
Members
446,239
Latest member
Home Nest

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top