S
Sidata
I am trying use names to ref to calculations.
in following code i can get all of the "names" to work ecept "prod"
Check = True: counter = 0: R = 50 ' Initialize variables.
Do ' Outer loop.
Do While counter < 1137 ' Inner loop.
R = 50 + counter 'start row
C = 16 'start Column
CloseStk = Cells(R, C).Value
CalcZero = Cells(R - 2, C) - Cells(R, C - 1)
MinWks = Val(Cells(R - 3, 11).Value) / 4
ERQ = Cells(R - 3, 9).Value
Demand1 = Cells(R - 2, C + 1).Value
Demand2 = Cells(R - 2, C + 2).Value
Demand3 = Cells(R - 2, C + 2).Value
Demand4 = Cells(R - 2, C + 2).Value
MthsC = Cells(R - 3, 10).Value
Prod = Cells(R - 1, C).Value
If Cells(R - 3, 1).Value = "Y" And Cells(R - 3, 2).Value = 1 Then
If Cells(R, C).Value = 0 Then
If MthsC = 1 Then
If Demand1 > 0 Then
Prod = CalcZero + Demand1 * (Cells(R - 3, 11).Value) /
4
Else: Prod = CalcZero
End If
ElseIf MthsC = 2 Then
If Demand1 > 0 And Demand2 = 0 Then
Prod = CalcZero + Demand1
Else:
Prod = CalcZero + Demand1 + Demand2 * MinWks
End If
ElseIf MthsC = 3 Then
Cells(R - 1, C) = CalcZero + Demand1 + Demand2 + Demand3 *
(Cells(R - 3, 11).Value) / 4
ElseIf MthsC = 4 Then
Cells(R - 1, C) = CalcZero + Demand1 + Demand2 + Demand3 +
Demand4 * (Cells(R - 3, 11).Value) / 4
Else: Cells(R - 1, C) = ERQ
End IF
End If
End If
counter = counter + 4 ' Increment Counter.
If counter > 1137 Then ' If condition is True.
Check = False ' Set value of flag to False.
Exit Do ' Exit inner loop.
End If
Loop
Loop Until Check = False ' Exit outer loop immediately.
Thanks for any help
in following code i can get all of the "names" to work ecept "prod"
Check = True: counter = 0: R = 50 ' Initialize variables.
Do ' Outer loop.
Do While counter < 1137 ' Inner loop.
R = 50 + counter 'start row
C = 16 'start Column
CloseStk = Cells(R, C).Value
CalcZero = Cells(R - 2, C) - Cells(R, C - 1)
MinWks = Val(Cells(R - 3, 11).Value) / 4
ERQ = Cells(R - 3, 9).Value
Demand1 = Cells(R - 2, C + 1).Value
Demand2 = Cells(R - 2, C + 2).Value
Demand3 = Cells(R - 2, C + 2).Value
Demand4 = Cells(R - 2, C + 2).Value
MthsC = Cells(R - 3, 10).Value
Prod = Cells(R - 1, C).Value
If Cells(R - 3, 1).Value = "Y" And Cells(R - 3, 2).Value = 1 Then
If Cells(R, C).Value = 0 Then
If MthsC = 1 Then
If Demand1 > 0 Then
Prod = CalcZero + Demand1 * (Cells(R - 3, 11).Value) /
4
Else: Prod = CalcZero
End If
ElseIf MthsC = 2 Then
If Demand1 > 0 And Demand2 = 0 Then
Prod = CalcZero + Demand1
Else:
Prod = CalcZero + Demand1 + Demand2 * MinWks
End If
ElseIf MthsC = 3 Then
Cells(R - 1, C) = CalcZero + Demand1 + Demand2 + Demand3 *
(Cells(R - 3, 11).Value) / 4
ElseIf MthsC = 4 Then
Cells(R - 1, C) = CalcZero + Demand1 + Demand2 + Demand3 +
Demand4 * (Cells(R - 3, 11).Value) / 4
Else: Cells(R - 1, C) = ERQ
End IF
End If
End If
counter = counter + 4 ' Increment Counter.
If counter > 1137 Then ' If condition is True.
Check = False ' Set value of flag to False.
Exit Do ' Exit inner loop.
End If
Loop
Loop Until Check = False ' Exit outer loop immediately.
Thanks for any help