View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
RB Smissaert RB Smissaert is offline
external usenet poster
 
Posts: 2,452
Default Formula in a cell (in Visual Basic)

Try this:

Sub Moy()

Dim Line As Integer

Line = 16
While Worksheets(1).Cells(Line, 13).Value < ""
Worksheets(1).Cells(Line, 16).FormulaR1C1 =
"=AVERAGE(RC[-3]:RC[-1])"
Line = Line + 1
Wend

End Sub

RBS

"imej-clavier" wrote in message
...
Can somebody understand why my program does not work ?
I have tried to put Cells, :, and so on but it does not work.
Private Sub Moy()
Dim Line As Integer
Line = 16
While Worksheets(1).Cells(Line, 13).Value < ""
Worksheets(1).Cells(Line, 16).Formula =
"=Average(Cells((Line,13),(Line,15)))"
Line = Line + 1
Wend
End Sub
Thank you in advance for the answer,

Jean-michel