T
todd
I am trying to compare values on worksheet1 to worksheet2, and copy some of
the data to worksheet3 based upon the if statement results. I've seen a
couple posts discussing what I am trying to do; tried their codes and my own,
and continue to get this error...
"Run-time error ‘1004’:
Application-defined or object-defined error"
The "if" line gets highlighted upon macro execution.
-----
Sub correlate()
Dim i, j, k As Integer
For i = 1 To 500 'correlation worksheet
For j = 2 To 11933 'ctsytd05 worksheet
For k = 2 To 14010 'srytd05 worksheet
If Worksheets("srytd05").Cells(4, k).Value =
Worksheets("ctsytd05").Cells(3, j).Value Then
Worksheets("correlation").Cells(1, i - 1).Value =
Worksheets("srytd05").Cells(4, k - 1).Value
Worksheets("correlation").Cells(2, i - 1).Value =
Worksheets("srytd05").Cells(8, k - 1).Value
Worksheets("correlation").Cells(3, i - 1).Value =
Worksheets("ctsytd05").Cells(1, j - 1).Value
End If
Next k
End
Next j
End
Next i
End
End Sub
the data to worksheet3 based upon the if statement results. I've seen a
couple posts discussing what I am trying to do; tried their codes and my own,
and continue to get this error...
"Run-time error ‘1004’:
Application-defined or object-defined error"
The "if" line gets highlighted upon macro execution.
-----
Sub correlate()
Dim i, j, k As Integer
For i = 1 To 500 'correlation worksheet
For j = 2 To 11933 'ctsytd05 worksheet
For k = 2 To 14010 'srytd05 worksheet
If Worksheets("srytd05").Cells(4, k).Value =
Worksheets("ctsytd05").Cells(3, j).Value Then
Worksheets("correlation").Cells(1, i - 1).Value =
Worksheets("srytd05").Cells(4, k - 1).Value
Worksheets("correlation").Cells(2, i - 1).Value =
Worksheets("srytd05").Cells(8, k - 1).Value
Worksheets("correlation").Cells(3, i - 1).Value =
Worksheets("ctsytd05").Cells(1, j - 1).Value
End If
Next k
End
Next j
End
Next i
End
End Sub