Bawn
Bawn

Reputation: 509

Copying excel Data to new worksheet Error 1004

I am trying to copy certain information from cells into another spread sheet. I have a For loop which loops through the rows. The program bugs out when I try to copy the cells into the new spread sheet. Should I be using range ? And do I need to say the worksheet before cells ?

This is just a sample of the code :

Set myOtherSheet = ThisWorkbook.Sheets("Sheet2")
For Each WkSht In ThisWorkbook.Worksheets
If WkSht.Name = "Sheet1" Then
j = 0
For r = 6 To 1000

myOtherSheet.Cells(j, 1).Value = WkSht.Cells(r, 2)
myOtherSheet.Cells(j, 2).Value = Match

There Error I get is a 1004 object defined error

Upvotes: 0

Views: 150

Answers (1)

matzone
matzone

Reputation: 5719

Might caused by j = 0 .. there's no rows 0 .. at least it should be ..

j = 1

Upvotes: 2

Related Questions