LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 284
Default Excel- find the last filled cells in column with empty cells

Here is a user defined function that should do what you want. Once you save
the function in a module, you should be able to enter
=AvLatestThree(O:O)
to get the average of the three last non blank values in column O. You
could change the column reference given to the formula to do the same thing
in other columns.

______________________________________

Function AvLatestThree(columnToCheck As Range)
Dim topRow As Integer
Dim valCount As Integer
Dim intTotal As Integer
Dim x As Integer
Dim valArray()

colNum = columnToCheck.Column
topRow = Cells(65536, colNum).End(xlUp).Row
valCount = 0

For R = 1 To topRow
If Application.WorksheetFunction.IsNumber(Cells(R, colNum)) Then
ReDim Preserve valArray(valCount)
valArray(valCount) = Cells(R, colNum).Value
valCount = valCount + 1
End If
Next R

If UBound(valArray) 1 Then
x = UBound(valArray)
intTotal = valArray(x) + valArray(x - 1) + valArray(x - 2)
AvLatestThree = intTotal / 3
Else
AvLatestThree = "Fewer than three values to average"
End If

End Function

_____________________________________

Steve



wrote in message
oups.com...
I have tried several times from other resources for help on this
problem to no avail.

I have a sheet that data in column O is ever expanding with new data
added to the bottom of the column.
Example.
120
blank cell
blank cell
175
blank cell
blank cell
blank cell
166
blank cell
blank cell
450
blank cell
blank cell
blank cell
blank cell
620

I am looking for a formula that will average the last three cells with
data. In this case 166+450+620/3=412
Blank cell is random.

Thank you in advance for your prompt attention to this matter.

Steven R. Dekker



 
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
Excel counting empty cells until first filled one Rafael Martinez Excel Discussion (Misc queries) 2 September 17th 09 05:20 PM
Macro Request: Fill in empty cells with previous Filled cell in column Artis Excel Worksheet Functions 2 June 25th 07 08:30 PM
Copy Data From Filled to Empty Cells Sheikh Saadi Excel Discussion (Misc queries) 0 November 10th 05 07:21 PM
How create a nonblank source for a verification list with a mix of filled & empty cells? Maria J-son Excel Programming 4 August 8th 05 07:17 PM
What must I do to get gridlines printed for both filled and empty cells? Hubert Earl Excel Programming 1 November 7th 04 08:33 PM


All times are GMT +1. The time now is 01:14 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"