Re: Do Loop until empty row (column "A")

Tech-Archive recommends: Fix windows errors by optimizing your registry




The last thread code did not work. I am using Range "P2" to start the
calculations in P2 and continue through Y2, then go to P3 through Y3,
etc. until the last row is reached. It is looping until the last row
but not filling out columns P - Y. Once finished, it displays
"#VALUE!" in P2 cell with the formulate B2/30 which should be in Y2.

Thanks,

Jim

Range("P2").Select
'
' Start of row calculations.
'
Dim rng As Range, i As Long
i = 2
Set rng = Cells(i, 1)
Do While Application.CountA(rng.Resize(1, 15)) <> 0
'
' Calculate columns P - Y (10 columns)
'
ActiveCell.FormulaR1C1 = "=IF(RC[-7]=0,""
"",(RC[-6]*1000)/RC[-7])"
ActiveCell.FormulaR1C1 = _
"=IF((RC[-8]+RC[-6])=0,"" "",(RC[-7]*1000)/(RC[-8]+RC[-6]))"
ActiveCell.FormulaR1C1 = "=IF(RC[-9]=0,"" "",RC[-7]/RC[-9])"
ActiveCell.FormulaR1C1 = _
"=IF((RC[-10]+RC[-8])=0,"" "",RC[-8]/(RC[-10]+RC[-8]))"
ActiveCell.FormulaR1C1 = "=IF(RC[-11]=0,""
"",RC[-10]/RC[-11])"
ActiveCell.FormulaR1C1 = "=IF(RC[-11]=0,""
"",RC[-12]/RC[-11])"
ActiveCell.FormulaR1C1 = "=IF(RC[-12]=0,""
"",RC[-11]/RC[-12])"
ActiveCell.FormulaR1C1 = "=SUM(RC[-14]/30)"
ActiveCell.FormulaR1C1 = "=SUM(RC[-14]/30)"
ActiveCell.FormulaR1C1 = "=SUM(RC[-14]/30)"
'
' Next row.
'
i = i + 1
Set rng = rng.Offset(1, 0)
Loop


--
Jim15
------------------------------------------------------------------------
Jim15's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=26300
View this thread: http://www.excelforum.com/showthread.php?threadid=395789

.



Relevant Pages

  • Re: Convert all text in a sheet to UpperCase?
    ... looping through the range of text to convert it to Ucase. ... Is there a command to convert all text in a sheet to UpperCase in one shot? ... Dim rng As Range, i As Integer, j As Integer ...
    (microsoft.public.excel.programming)
  • Re: Convert all text in a sheet to UpperCase?
    ... looping through the range of text to convert it to Ucase. ... Is there a command to convert all text in a sheet to UpperCase in one shot? ... Dim rng As Range, i As Integer, j As Integer ...
    (microsoft.public.excel.programming)
  • Re: If sheet has no #N/A error then...
    ... you mean looping is not good enough ... Dim rng as Range ... Is there a way to quickly check that all DDE links have been updated? ... I can check that every cell is not error but that is not good enough. ...
    (microsoft.public.excel.programming)