Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Formula in a cell (in Visual Basic)

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Formula in a cell (in Visual Basic)

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)


"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




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
Visual Basic insert formula Pavlov Bell Excel Discussion (Misc queries) 2 October 25th 10 06:30 PM
Adding a dymanic formula to a cell using visual basic Ian Web Excel Discussion (Misc queries) 2 September 28th 06 09:59 PM
Adding a dymanic formula to a cell using visual basic Ian Web Excel Discussion (Misc queries) 0 September 28th 06 09:26 PM
Visual basic Check Box and the IF formula dingo33 Excel Discussion (Misc queries) 3 February 15th 06 04:57 PM
Formula in Visual Basic For Excel imej-clavier Excel Discussion (Misc queries) 2 December 23rd 04 01:43 PM


All times are GMT +1. The time now is 08:02 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"