Loop in a Range
I am trying to make a loop that calculate each cell to the right of the
"RngMdDp1"-range, based on the value in cell "I3" and "RngMdDp1" . The cells in "RngMdDp1" gets higher values for each cells, so at one cell there sould be a breaking point, and the formula would be changed. can anyone se whats wrong with the macro? Sub DrillPipe1() For Each c In Range("RngMdDp1") If c.Value < ("I3") Then c.Offset(0, 1).FormulaR1C1 = "=(RC[-1]*RC[-2])" Else c.Offset(0, 1).FormulaR1C1 = "=(RC[-1])" Next c End Sub |
Loop in a Range
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 -- Regards, Tom Ogilvy "aksel børve" wrote in message ... I am trying to make a loop that calculate each cell to the right of the "RngMdDp1"-range, based on the value in cell "I3" and "RngMdDp1" . The cells in "RngMdDp1" gets higher values for each cells, so at one cell there sould be a breaking point, and the formula would be changed. can anyone se whats wrong with the macro? Sub DrillPipe1() For Each c In Range("RngMdDp1") If c.Value < ("I3") Then c.Offset(0, 1).FormulaR1C1 = "=(RC[-1]*RC[-2])" Else c.Offset(0, 1).FormulaR1C1 = "=(RC[-1])" Next c End Sub |
Loop in a Range
Thanks for your solutionOgilvy! And thanks to all the programmers who has
helpt me with my questions. 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) "Tom Ogilvy" skrev i melding ... 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 -- Regards, Tom Ogilvy "aksel børve" wrote in message ... I am trying to make a loop that calculate each cell to the right of the "RngMdDp1"-range, based on the value in cell "I3" and "RngMdDp1" . The cells in "RngMdDp1" gets higher values for each cells, so at one cell there sould be a breaking point, and the formula would be changed. can anyone se whats wrong with the macro? Sub DrillPipe1() For Each c In Range("RngMdDp1") If c.Value < ("I3") Then c.Offset(0, 1).FormulaR1C1 = "=(RC[-1]*RC[-2])" Else c.Offset(0, 1).FormulaR1C1 = "=(RC[-1])" Next c End Sub |
All times are GMT +1. The time now is 03:36 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com