Hi there,
I am trying to copy and paste stuffs by matching cells on two worksheets doing loops with matching criterias. The cells from worksheet "input" that I am matching doesn't stay at the same column all the time, so the way I came up to get to the cell I want all the time is to do a column count at the matching row, and then use the last column number to shift back to get to the matching criteria I need consistently. The following code, for some reason, doesn't work. What could be wrong? Any suggestions? Thanks a bunch.
Code
'Diameters
InputLastRow = Worksheets("Input").UsedRange.Rows.Count
PipeSectionLastRow = Worksheets("Pipe Sections").UsedRange.Rows.Count
BallStiffnessLastRow = Worksheets("Ball Stiffness").UsedRange.Rows.Count
For BallStiffnessStartRow = 1 To BallStiffnessLastRow Step 1
For InputStartRow = 1 To InputLastRow Step 1
For PipeSectionStartRow = 1 To PipeSectionLastRow Step 1
If Worksheets("Ball Stiffness").Cells(BallStiffnessStartRow, 1) = Worksheets("Input").Cells(InputStartRow, 2) Then
InputLastColumn = Worksheets("Input").Rows(InputStartRow).UsedRange.Columns.Count
If Worksheets("Input").Cells(InputStartRow, InputLastColumn - 1) = Worksheets("Pipe Sections").Cells(PipeSectionStartRow, 1) Then
Worksheets("Pipe Sections").Range("D" & PipeSectionStartRow).Copy _
Destination:=Worksheets("Master Sheet (Couplings)").Range("E" & BallStiffnessStartRow + 3)
End If
End If
Next PipeSectionStartRow
Next InputStartRow
Next BallStiffnessStartRow
Display More