View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
pardoxchic pardoxchic is offline
external usenet poster
 
Posts: 2
Default Populating IF Formula while looping - trouble with index interpret

I need to populate this IF into all cells in my spreadsheet (many others to
do as well). Somehow, my code is inserting the row index but it's the
variable name and not the value,,,resulting in this value
=IF(O(rIndex)=0,0,N(rIndex)/O(rIndex))

What am I missing? Is there an easier way to do this? Users may or may not
have 2007 loaded - will that be a consideration? Newbie to Excel coding!

Sub var_RE()
rIndex = 2 'set row to 2
For rIndex = 2 To 12
Cells(rIndex, 17).Formula = "=IF( [RE_Current] = 0, 0,
[Total_MTD] / [RE_Current])"
Next rIndex
End Sub