ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   calculate cell before moving to next cell (https://www.excelbanter.com/excel-programming/355937-calculate-cell-before-moving-next-cell.html)

Sliman

calculate cell before moving to next cell
 
I have the following code :-

Check = True: Counter = 0: r = 50 ' Initialize variables.
Do ' Outer loop.
Do While Counter < 1137 ' Inner loop.
r = 50 + Counter 'start row
For C = 15 To 25 'start Column

If Cells(r - 3, 1).Value = "Y" And Cells(r - 3, 2).Value = 3 Then
Cells(r - 1, C).Clear
If Cells(r, C).Value = 0 Then
Cells(r - 1, C).Value = (Cells(r - 2, C).Value - Cells(r, C -
1).Value) _
+ ((Cells(r - 2, C + 1).Value) * (Cells(r - 3, 11).Value) / 4)
ElseIf (Cells(r, C).Value < (Cells(r - 2, C + 1).Value) * (Cells(r
- 3, 11).Value) / 4) Then
Cells(r - 1, C).Value = (Cells(r - 2, C + 1).Value + Cells(r - 2, C
+ 2).Value)
End If
End If
Next C

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.

But need the formula in Cellc(r,C) to recalculate before moving to next
c.
I have Autocalulate off as takes to long to run with Autocalulate On


Rob[_28_]

calculate cell before moving to next cell
 
add the line
Application.Calculate


"Sliman" wrote in message
ups.com...
I have the following code :-

Check = True: Counter = 0: r = 50 ' Initialize variables.
Do ' Outer loop.
Do While Counter < 1137 ' Inner loop.
r = 50 + Counter 'start row
For C = 15 To 25 'start Column

If Cells(r - 3, 1).Value = "Y" And Cells(r - 3, 2).Value = 3 Then
Cells(r - 1, C).Clear
If Cells(r, C).Value = 0 Then
Cells(r - 1, C).Value = (Cells(r - 2, C).Value - Cells(r, C -
1).Value) _
+ ((Cells(r - 2, C + 1).Value) * (Cells(r - 3, 11).Value) / 4)
ElseIf (Cells(r, C).Value < (Cells(r - 2, C + 1).Value) * (Cells(r
- 3, 11).Value) / 4) Then
Cells(r - 1, C).Value = (Cells(r - 2, C + 1).Value + Cells(r - 2, C
+ 2).Value)
End If
End If
Next C

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.

But need the formula in Cellc(r,C) to recalculate before moving to next
c.
I have Autocalulate off as takes to long to run with Autocalulate On





All times are GMT +1. The time now is 07:43 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com