montecarlo2012
Well-known Member
- Joined
- Jan 26, 2011
- Messages
- 984
- Office Version
- 2010
- Platform
- Windows
Hi.
This is what I am trying to do
Range("B11").Formula = "=average(B1:XX1)" ' average distribution B1
Range("B27").Formula = "=average(B17:XX17)" ' average distribution B17
Range("B43").Formula = "=average(B33:XX33)" ' average distribution B33
Range("B59").Formula = "=average(B49:XX49)" ' average distribution B49
Range("B75").Formula = "=average(B65:XX65)" ' average distribution B65
Range("B91").Formula = "=average(B81:XX81)" ' average distribution B81
So as long as I use this basic writing, I got my results, but when I write a little code
then the screen is blinking tremendously and even with application.screenupdate.
Plus no result.
Please can you tell me my mistakes, thanks
this is my code:
This is what I am trying to do
Range("B11").Formula = "=average(B1:XX1)" ' average distribution B1
Range("B27").Formula = "=average(B17:XX17)" ' average distribution B17
Range("B43").Formula = "=average(B33:XX33)" ' average distribution B33
Range("B59").Formula = "=average(B49:XX49)" ' average distribution B49
Range("B75").Formula = "=average(B65:XX65)" ' average distribution B65
Range("B91").Formula = "=average(B81:XX81)" ' average distribution B81
So as long as I use this basic writing, I got my results, but when I write a little code
then the screen is blinking tremendously and even with application.screenupdate.
Plus no result.
Please can you tell me my mistakes, thanks
this is my code:
VBA Code:
sub avg_m ()
Dim im As Long, cln As Long, XX As Long
XX = 1
For im = 1 To 81 Step 16
For cln = 2 To Cells(2, Columns.Count).End(xlToLeft).Column
Cells(im, "B").Formula = "=average(" & Cells(im, "B").Address & ":" & Cells(im, "XX").Address & ")"
XX = XX + 16
Next
Next
end sub