sweater_vests_rock
Well-known Member
- Joined
- Oct 8, 2004
- Messages
- 1,657
The following code is coming up with a 1004 error (Application-defined or Object defined error). Why?
counter_rowX is a Long
worksheet_name(X) is a String array containing the names of the worksheets
column_name(X) is a String containing the name of the column used to find matches.
column_count(X) is an Integer array containing the name of the last column in the range in worksheet X
output_sheet_name is a String
row_count(X) is a Long array containing the name of the last row in worksheet X.
I've checked to make sure all of the values showing up in these variables are appropriate and logical.
counter_rowX is a Long
worksheet_name(X) is a String array containing the names of the worksheets
column_name(X) is a String containing the name of the column used to find matches.
column_count(X) is an Integer array containing the name of the last column in the range in worksheet X
output_sheet_name is a String
row_count(X) is a Long array containing the name of the last row in worksheet X.
I've checked to make sure all of the values showing up in these variables are appropriate and logical.
Code:
Do
counter_row1 = counter_row1 + 1
counter_row2 = 0
Do
counter_row2 = counter_row2 + 1
If Worksheets(worksheet_name(1)).Cells(counter_row1, column_name(1)) = Worksheets(worksheet_name(2)).Cells(counter_row2, column_name(2)) Then
counter_row3 = counter_row3 + 1
Worksheets(worksheet_name(1)).Range(Cells(counter_row1, 1), Cells(counter_row1, column_count(1))).Copy (Worksheets(output_sheet_name).Range(Cells(counter_row3, 1), Cells(counter_row3, column_count(1))))
Worksheets(worksheet_name(2)).Range(Cells(counter_row2, 1), Cells(counter_row2, column_count(2))).Copy (Worksheets(output_sheet_name).Range(Cells(counter_row3, column_count(1) + 1), Cells(counter_row3, (column_count(1) + 1) + column_count(1))))
End If
Loop While counter_row2 < row_count(2)
Loop While counter_row1 < row_count(1)