Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default 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






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Loop through Range and Cut and Paste Kevin L Excel Programming 2 February 16th 05 06:19 PM
Loop through a range Fred[_21_] Excel Programming 6 October 22nd 04 10:45 PM
using For each loop to populate a range Sean Excel Programming 2 September 30th 04 02:13 PM
Changing range name in loop Jeff Excel Programming 4 July 12th 04 08:32 PM
Increasing a range in a loop ric Excel Programming 4 April 26th 04 07:59 PM


All times are GMT +1. The time now is 01:20 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"