Hello All,
I'm trying to find information in a second spreadsheet that matches information from the first and then return the found values back to the first spreadsheet. The problem is it doesn't seem to be looping through all of the data in the second spreadsheet. The code looks like this...
Sub Calculate()
Dim I As Integer
Dim RowOff As Integer
Dim Machine As Range
I = 0
RowOff = 0
Set Machine = Range("B2")
Select Case Machine
Case "21"
Sheets(1).Range("B3:B4").Copy
Sheets("21").Activate
Range("L1:L2").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveSheet.Calculate
For I = 1 To 160
If Sheets(2).Range("A2").Offset(RowOff, 0).Value = Sheets(2).Range("L1").Value Then
If Sheets(2).Range("L2").Value >= Sheets(2).Range("B2").Offset(RowOff, 0).Value _
And Sheets(2).Range("L2").Value <= Range("C2").Offset(RowOff, 0).Value Then
Sheets(2).Range("B2:J2").Offset(RowOff, 0).Copy
Sheets(1).Activate
Range("A14").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Exit For
Else
End If
End If
Count = Count + 1
RowOff = RowOff + 1
Next I
Sheets(1).Activate
End Select
Application.CutCopyMode = False
End Sub
]Scheduling Tool.xlsm
I've also attached the spreadsheet. I hope to be able to take this code and apply it to a much larger data set. Let me know If you need any more information, any and all help is appreciated.
Bookmarks