Help?? Averaging cells

  • Thread starter Thread starter PaulSinki
  • Start date Start date
P

PaulSinki

Okay, I'm stumped here.
I want to be able to write a macro that will go down a list of cells,
and if the offset(0,-1) is blank, then will execute code. That part
I've written. But what I need it to do is fill any blank cells to the
left with the average of the first cell and the next cell with data.
Ie Row 365 has a value of 9 in column E. There are blank cells in
column D & C, and in column B there is a value of 3. I want the macro
to work out the average of 3 and 9, and put the answer, 6, in cells
C365 & D365. The number of gaps between cells will vary, so I was
wanting to use a xlToLeft, but how can I get it to work out the
averages of the two cells with values in them?
Thanks
Paul
 
for each cell in Range(whatever)
num = Application.Average(Cell, cell.End(xlToLeft))
for col = cell.End(xltoLeft).Column + 1 to cell.Column - 1 then
cells(cell.row,col) = num
Next
Next
 
Back
Top