Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Help?? Averaging cells

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


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Help?? Averaging cells


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

--
Regards,
Tom Ogilvy

"PaulSinki" wrote in message
...
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


---
Message posted from http://www.ExcelForum.com/



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
Averaging with #N/A Cells tylermdsm Excel Discussion (Misc queries) 4 February 22nd 08 06:46 PM
averaging cells Ravens Fan Excel Discussion (Misc queries) 9 November 30th 07 05:53 PM
Averaging Cells Based On Conditions in Neighboring Cells foofoo Excel Discussion (Misc queries) 3 June 21st 06 03:10 AM
Averaging Cells Daniel9684 Excel Discussion (Misc queries) 3 February 17th 06 07:21 PM
Averaging cells which contain #DIV/0! maryj Excel Worksheet Functions 4 November 4th 04 01:32 PM


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