Hi!!
Im wondering if anyone can help, below is the code ive written so far and as it is, works well but what i need is the route number to be a variable which can be read from a cell range ie if the route range is C1:C70, it uses the value of C1 then moves onto C2 then C3 etc, im not sure whats the correct way to achieve this.
also the pcell variable id like to do a similar thing with this, ie starts at 10, then at the end of the code + 1 then runs the code again with a new route from the range above
Im sure what i need is simple, i just can't seem to work out the best way to do it
Any help would be greatly appreciated!
Im wondering if anyone can help, below is the code ive written so far and as it is, works well but what i need is the route number to be a variable which can be read from a cell range ie if the route range is C1:C70, it uses the value of C1 then moves onto C2 then C3 etc, im not sure whats the correct way to achieve this.
also the pcell variable id like to do a similar thing with this, ie starts at 10, then at the end of the code + 1 then runs the code again with a new route from the range above
Im sure what i need is simple, i just can't seem to work out the best way to do it
Any help would be greatly appreciated!
Code:
SCAM = 1041
SCPM = 1042
r300d = 0
r300c = 0
Route = 300 'Route Number
pcell = 10 'Cell Paste Location
For n = 8 To lastRow
If (Left(Sheets("Source").Cells(n, 3), 7) = SCAM & Route) And (Left(Sheets("Source").Cells(n, 10), 3) = "Del") Or _
(Left(Sheets("Source").Cells(n, 3), 7) = SCPM & Route) And (Left(Sheets("Source").Cells(n, 10), 3) = "Del") Then
r300d = r300d + 1
End If
Next n
For n = 8 To lastRow
If (Left(Sheets("Source").Cells(n, 3), 7) = SCAM & Route) And (Left(Sheets("Source").Cells(n, 10), 3) = "Col") Or _
(Left(Sheets("Source").Cells(n, 3), 7) = SCPM & Route) And (Left(Sheets("Source").Cells(n, 10), 3) = "Col") Then
r300c = r300c + 1
End If
Next n
For n = 8 To lastRow
If (Left(Sheets("Source").Cells(n, 3), 7) = SCAM & Route) Then
Sheets("results").Cells(6, 3).Value = Sheets("Source").Cells(n, 1).Value
Sheets("results").Cells(pcell, 2).Value = Sheets("Source").Cells(n, 13).Value
Sheets("results").Cells(pcell, 3).Value = r300c
Sheets("results").Cells(pcell, 4).Value = r300d
End If
Next n