I'm just matching two cells and then copying and pasting from one worksheet to another, the copy line gives me an "Application Defined or Object Defined Error".
Code:
Sub Add_Forecast_Data_to_Demand_Data()
Dim totalrows1 As Long, totalrows2 As Long, iRow1 As Long, iRow2 As Long, part1 As String, part2 As String
Dim loc1 As String, loc2 As String
totalrows1 = Sheets("Parts_Locs_Merged_Rows").UsedRange.Rows.Count
totalrows2 = Sheets("Forecast_June").UsedRange.Rows.Count
For iRow2 = 2 To 10
part2 = Sheets("Forecast_June").Cells(iRow2, 1)
loc2 = Sheets("Forecast_June").Cells(iRow2, 2)
For iRow1 = 2 To totalrows1
part1 = Sheets("Parts_Locs_Merged_Rows").Cells(iRow1, 1)
loc1 = Sheets("Parts_Locs_Merged_Rows").Cells(iRow1, 2)
If (part1 = part2 And loc1 = loc2) Then
Sheets("Forecast_June").Range(Cells(iRow2, 3), Cells(iRow2, 15)).Copy
Sheets("Parts_Locs_Merged_Rows").Cells(iRow1, 15).PasteSpecial xlPasteValues
Exit For
End If
Next iRow1
Next iRow2
End Sub
Last edited: