Formula in a cell (in Visual Basic)

  • Thread starter Thread starter imej-clavier
  • Start date Start date
I

imej-clavier

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
 
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
 
Private Sub Moy()
Dim Line As Integer
Line = 16
While Worksheets(1).Cells(Line, 13).Value <> ""
Worksheets(1).Cells(Line, 16).Formula = "=Average(M" & Line & ":O" &
Line & ")"
Line = Line + 1
Wend
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top