Sub
You would put it in a separate sub, and pass the variables as arguments. As
you dont say what are the variables, it is difficulet to guess, but
something like this
GenericRoutine DailyDischargeBel, TotalDischargeBelt
Sub GenericRoutine(var1, var2)
Ctr = 0
For Ctr = 1 To 16
var1(Ctr) = Sheets("MinorStops").Cells
(1 + Ctr, 4).Value
var2(Ctr) = Sheets("MinorStops").Cells
(1 + Ctr, 5).Value
var2(Ctr) = var1(Ctr) + var2(Ctr)
Sheets("MinorStops").Cells(1 + Ctr, 5).Value = var2(Ctr)
Next Ctr
End SUb
--
HTH
RP
(remove nothere from the email address if mailing direct)
"Pete" wrote in message
...
I execute this piece of code 5 times during a Sub, can
anyone tell me how to write a procedure that can be
generic e.g
Sub MyProcedure(DailyDischargeBelt(),TotalDischargBelt
(),Col,Col1)
Then ratehr that typing all of the below in 5 times
changing the variables, the procedure would handle that
for me
Ctr = 0
For Ctr = 1 To 16
DailyDischargeBelt(Ctr) = Sheets("MinorStops").Cells
(1 + Ctr, 4).Value
TotalDischargeBelt(Ctr) = Sheets("MinorStops").Cells
(1 + Ctr, 5).Value
TotalDischargeBelt(Ctr) = TotalDischargeBelt(Ctr) +
DailyDischargeBelt(Ctr)
Sheets("MinorStops").Cells(1 + Ctr, 5).Value =
TotalDischargeBelt(Ctr)
Next Ctr
Hope that makes sense
Pete
|