Thread: Loop in a Range
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Aksel Børve Aksel Børve is offline
external usenet poster
 
Posts: 21
Default 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