Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks for your solutionOgilvy! but am not able to make the macro work. And
thanks to all you programmers who has helpt me with my questions. (It's not easy to be an Copy and Paste Programmer!) My problem is that I want to calculate every cell to the right from "RngMdDp1", based on the value on every cell in "RngMdDp1"That meens cells(O2:O115). compare to the value in cell (I3) Example: The Cell that is used to see witch calculation to use Cell ("I3") value = 1358 Example of the breaking point I wont in the ("RngMdDp1") Cell ("O55") value = 1355. Then it uses the first Calculation. "=(RC[-1]*RC[-2])" Cell ("O56") value = 1357. Then it uses the first Calculation. "=(RC[-1]*RC[-2])" Cell ("O57") value = 1359. Then it uses the second Calculation. "=(RC[-1])" Cell ("O57") value = 1361. Then it uses the second Calculation. "=(RC[-1])" I hope that I have explain so you anderstand my problems. Below is some of the macro I have used. That dont work. ----------------------------------------------------------------------------------- Sub DrillPipe1() Dim c as Range For Each c In Range("RngMdDp1") If c.Value < Range("I3") Then c.Offset(0, 1).FormulaR1C1 = _ "=(RC[-1]*RC[-2])" Else c.Offset(0, 1).FormulaR1C1 = "=(RC[-1])" End if Next c End Sub --------------------------------------------------------------------------------- Sub DrillPipe1() For Each cell_in_loop In Range("RngMdDp1") If (cell_in_loop.Value Range("I3").Value) Then cell_in_loop.Offset(0, 1).FormulaR1C1 = _ "=(RC[-1]*RC[-2])" Else cell_in_loop.Offset(0, 1).FormulaR1C1 = "=(RC[-1])" Exit For End If Next cell_in_loop End Sub Thanks for you'rs time Aksel |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
reset the range of FOR loop | Excel Discussion (Misc queries) | |||
Loop in a Range | Excel Programming | |||
Loop Through Highlighted Range | Excel Programming | |||
Loop through a range | Excel Programming | |||
using For each loop to populate a range | Excel Programming |