Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 695
Default AVERAGE(with complicated range -blanks..)

I got som values in Range("A10:A100")
There are some empty cells inbetwin
The 'list' grows but only inbetwin row 10 and row 100
There are values before and after 'my' range that i dont wana use

So how do i make a AVERAGE-formula for the 6 last values in my range?

I no how to find the last not emty ROW in my range:
MAX(IF(A10:A100<"";ROW(A10:A100)))

But how to find 6 not empty cells before that cell (still inbetwin 10-100)
e.g.#.1
..............A
row.1 | empty
...........
row.8 | empty
row.9 | 3
-----------------------------
row10 | empty
row11 | 1
row12 | 3
row13 | empty
row14 | empty
row15 | 2
row16 | 4
row17 | 1
row18 | 3
row19 | 5
row20 | empty
row21 | empty
row22 | empty
..........
row100 | empty

In this e.g. i ned to add A19,A18,A17,A16,A15 and A12 (6 values)

e.g.#.2
.............A
row.1 | empty
...........
row.7 | empty
row.8 | 2
row.9 | 3
-----------------------------
row10 | empty
row11 | 1
row12 | 3
row13 | empty
row14 | empty
row15 | 2
row16 | 4
row17 | empty
row18 | empty
row19 | empty
..........
row100 | empty

In this e.g. i ned to add A16,A16,A12,A11 (4 values )
so if there is les than 6 values in my range i only use them.

I dont wana use vba, pivot, filter, or rearrange my data.
so any help would be greatfull :-)

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,124
Default AVERAGE(with complicated range -blanks..)

try

Sub averagelast6withvalue()
n = 0
For i = Cells(Rows.Count, "a").End(xlUp).Row To 1 Step -1
If Not IsEmpty(Cells(i, "a")) Then ' MsgBox Cells(i, "a").Address
mysum = mysum + Cells(i, "a")
n = n + 1
End If
If n = 6 Then Exit For
Next i
MsgBox mysum / 6
End Sub

--
Don Guillett
SalesAid Software

"excelent" wrote in message
...
I got som values in Range("A10:A100")
There are some empty cells inbetwin
The 'list' grows but only inbetwin row 10 and row 100
There are values before and after 'my' range that i dont wana use

So how do i make a AVERAGE-formula for the 6 last values in my range?

I no how to find the last not emty ROW in my range:
MAX(IF(A10:A100<"";ROW(A10:A100)))

But how to find 6 not empty cells before that cell (still inbetwin 10-100)
e.g.#.1
.............A
row.1 | empty
..........
row.8 | empty
row.9 | 3
-----------------------------
row10 | empty
row11 | 1
row12 | 3
row13 | empty
row14 | empty
row15 | 2
row16 | 4
row17 | 1
row18 | 3
row19 | 5
row20 | empty
row21 | empty
row22 | empty
.........
row100 | empty

In this e.g. i ned to add A19,A18,A17,A16,A15 and A12 (6 values)

e.g.#.2
............A
row.1 | empty
..........
row.7 | empty
row.8 | 2
row.9 | 3
-----------------------------
row10 | empty
row11 | 1
row12 | 3
row13 | empty
row14 | empty
row15 | 2
row16 | 4
row17 | empty
row18 | empty
row19 | empty
.........
row100 | empty

In this e.g. i ned to add A16,A16,A12,A11 (4 values )
so if there is les than 6 values in my range i only use them.

I dont wana use vba, pivot, filter, or rearrange my data.
so any help would be greatfull :-)



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,688
Default AVERAGE(with complicated range -blanks..)

Try this:

Array entered:

=AVERAGE(A100:INDEX(A10:A100,LARGE(IF(A10:A100,ROW (A10:A100)-ROW(A10)+1),MIN(6,COUNT(A10:A100)))))

Note: if there are *no" numbers in the range you'll get a #NUM! error.

Biff

"excelent" wrote in message
...
I got som values in Range("A10:A100")
There are some empty cells inbetwin
The 'list' grows but only inbetwin row 10 and row 100
There are values before and after 'my' range that i dont wana use

So how do i make a AVERAGE-formula for the 6 last values in my range?

I no how to find the last not emty ROW in my range:
MAX(IF(A10:A100<"";ROW(A10:A100)))

But how to find 6 not empty cells before that cell (still inbetwin 10-100)
e.g.#.1
.............A
row.1 | empty
..........
row.8 | empty
row.9 | 3
-----------------------------
row10 | empty
row11 | 1
row12 | 3
row13 | empty
row14 | empty
row15 | 2
row16 | 4
row17 | 1
row18 | 3
row19 | 5
row20 | empty
row21 | empty
row22 | empty
.........
row100 | empty

In this e.g. i ned to add A19,A18,A17,A16,A15 and A12 (6 values)

e.g.#.2
............A
row.1 | empty
..........
row.7 | empty
row.8 | 2
row.9 | 3
-----------------------------
row10 | empty
row11 | 1
row12 | 3
row13 | empty
row14 | empty
row15 | 2
row16 | 4
row17 | empty
row18 | empty
row19 | empty
.........
row100 | empty

In this e.g. i ned to add A16,A16,A12,A11 (4 values )
so if there is les than 6 values in my range i only use them.

I dont wana use vba, pivot, filter, or rearrange my data.
so any help would be greatfull :-)



  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 695
Default AVERAGE(with complicated range -blanks..)

hi don. tks. for reply, it dosent sems to return the rigth average value
and i prefer a excel-formula - bif's is close to what im looking for
just ned it to ignore 0 and text too - ill tell him now :-)
so if u got a formula to fix that im all ears lol.

"Don Guillett" skrev:

try

Sub averagelast6withvalue()
n = 0
For i = Cells(Rows.Count, "a").End(xlUp).Row To 1 Step -1
If Not IsEmpty(Cells(i, "a")) Then ' MsgBox Cells(i, "a").Address
mysum = mysum + Cells(i, "a")
n = n + 1
End If
If n = 6 Then Exit For
Next i
MsgBox mysum / 6
End Sub

--
Don Guillett
SalesAid Software

"excelent" wrote in message
...
I got som values in Range("A10:A100")
There are some empty cells inbetwin
The 'list' grows but only inbetwin row 10 and row 100
There are values before and after 'my' range that i dont wana use

So how do i make a AVERAGE-formula for the 6 last values in my range?

I no how to find the last not emty ROW in my range:
MAX(IF(A10:A100<"";ROW(A10:A100)))

But how to find 6 not empty cells before that cell (still inbetwin 10-100)
e.g.#.1
.............A
row.1 | empty
..........
row.8 | empty
row.9 | 3
-----------------------------
row10 | empty
row11 | 1
row12 | 3
row13 | empty
row14 | empty
row15 | 2
row16 | 4
row17 | 1
row18 | 3
row19 | 5
row20 | empty
row21 | empty
row22 | empty
.........
row100 | empty

In this e.g. i ned to add A19,A18,A17,A16,A15 and A12 (6 values)

e.g.#.2
............A
row.1 | empty
..........
row.7 | empty
row.8 | 2
row.9 | 3
-----------------------------
row10 | empty
row11 | 1
row12 | 3
row13 | empty
row14 | empty
row15 | 2
row16 | 4
row17 | empty
row18 | empty
row19 | empty
.........
row100 | empty

In this e.g. i ned to add A16,A16,A12,A11 (4 values )
so if there is les than 6 values in my range i only use them.

I dont wana use vba, pivot, filter, or rearrange my data.
so any help would be greatfull :-)




  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 695
Default AVERAGE(with complicated range -blanks..)

hi Biff. tks. for reply
ur formula coms close to what im looking for.
do u think u can modify it, so it wil ignore 0 (cero) and text too ?
sry i didnt say that befor but i didnt no then that they could be present
in my list-range

"Biff" skrev:

Try this:

Array entered:

=AVERAGE(A100:INDEX(A10:A100,LARGE(IF(A10:A100,ROW (A10:A100)-ROW(A10)+1),MIN(6,COUNT(A10:A100)))))

Note: if there are *no" numbers in the range you'll get a #NUM! error.

Biff

"excelent" wrote in message
...
I got som values in Range("A10:A100")
There are some empty cells inbetwin
The 'list' grows but only inbetwin row 10 and row 100
There are values before and after 'my' range that i dont wana use

So how do i make a AVERAGE-formula for the 6 last values in my range?

I no how to find the last not emty ROW in my range:
MAX(IF(A10:A100<"";ROW(A10:A100)))

But how to find 6 not empty cells before that cell (still inbetwin 10-100)
e.g.#.1
.............A
row.1 | empty
..........
row.8 | empty
row.9 | 3
-----------------------------
row10 | empty
row11 | 1
row12 | 3
row13 | empty
row14 | empty
row15 | 2
row16 | 4
row17 | 1
row18 | 3
row19 | 5
row20 | empty
row21 | empty
row22 | empty
.........
row100 | empty

In this e.g. i ned to add A19,A18,A17,A16,A15 and A12 (6 values)

e.g.#.2
............A
row.1 | empty
..........
row.7 | empty
row.8 | 2
row.9 | 3
-----------------------------
row10 | empty
row11 | 1
row12 | 3
row13 | empty
row14 | empty
row15 | 2
row16 | 4
row17 | empty
row18 | empty
row19 | empty
.........
row100 | empty

In this e.g. i ned to add A16,A16,A12,A11 (4 values )
so if there is les than 6 values in my range i only use them.

I dont wana use vba, pivot, filter, or rearrange my data.
so any help would be greatfull :-)






  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 256
Default AVERAGE(with complicated range -blanks..)

Try...

=AVERAGE(IF(ROW(A10:A100)=LARGE(IF(ISNUMBER(A10:A 100),IF(A10:A1000,ROW(
A10:A100))),MIN(6,COUNTIF(A10:A100,"0"))),IF(ISNU MBER(A10:A100),IF(A10:A
1000,A10:A100))))

....confirmed with CONTROL+SHIFT+ENTER, not just ENTER.

Hope this helps!

In article ,
excelent wrote:

hi Biff. tks. for reply
ur formula coms close to what im looking for.
do u think u can modify it, so it wil ignore 0 (cero) and text too ?
sry i didnt say that befor but i didnt no then that they could be present
in my list-range

"Biff" skrev:

Try this:

Array entered:

=AVERAGE(A100:INDEX(A10:A100,LARGE(IF(A10:A100,ROW (A10:A100)-ROW(A10)+1),MIN
(6,COUNT(A10:A100)))))

Note: if there are *no" numbers in the range you'll get a #NUM! error.

Biff

"excelent" wrote in message
...
I got som values in Range("A10:A100")
There are some empty cells inbetwin
The 'list' grows but only inbetwin row 10 and row 100
There are values before and after 'my' range that i dont wana use

So how do i make a AVERAGE-formula for the 6 last values in my range?

I no how to find the last not emty ROW in my range:
MAX(IF(A10:A100<"";ROW(A10:A100)))

But how to find 6 not empty cells before that cell (still inbetwin
10-100)
e.g.#.1
.............A
row.1 | empty
..........
row.8 | empty
row.9 | 3
-----------------------------
row10 | empty
row11 | 1
row12 | 3
row13 | empty
row14 | empty
row15 | 2
row16 | 4
row17 | 1
row18 | 3
row19 | 5
row20 | empty
row21 | empty
row22 | empty
.........
row100 | empty

In this e.g. i ned to add A19,A18,A17,A16,A15 and A12 (6 values)

e.g.#.2
............A
row.1 | empty
..........
row.7 | empty
row.8 | 2
row.9 | 3
-----------------------------
row10 | empty
row11 | 1
row12 | 3
row13 | empty
row14 | empty
row15 | 2
row16 | 4
row17 | empty
row18 | empty
row19 | empty
.........
row100 | empty

In this e.g. i ned to add A16,A16,A12,A11 (4 values )
so if there is les than 6 values in my range i only use them.

I dont wana use vba, pivot, filter, or rearrange my data.
so any help would be greatfull :-)




  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 256
Default AVERAGE(with complicated range -blanks..)

Actually, the last ISNUMBER condition is not necessary. The following
should suffice...

=AVERAGE(IF(ROW(A10:A100)=LARGE(IF(ISNUMBER(A10:A 100),IF(A10:A1000,ROW(
A10:A100))),MIN(6,COUNTIF(A10:A100,"0"))),IF(A10: A1000,A10:A100)))

....confirmed with CONTROL+SHIFT+ENTER.

Hope this helps!

In article ,
Domenic wrote:

Try...

=AVERAGE(IF(ROW(A10:A100)=LARGE(IF(ISNUMBER(A10:A 100),IF(A10:A1000,ROW(
A10:A100))),MIN(6,COUNTIF(A10:A100,"0"))),IF(ISNU MBER(A10:A100),IF(A10:A
1000,A10:A100))))

...confirmed with CONTROL+SHIFT+ENTER, not just ENTER.

Hope this helps!

  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 695
Default AVERAGE(with complicated range -blanks..)

wohoo Domenic ur the mann :-) did that help ?.. oh yeaaah great job




"Domenic" skrev:

Actually, the last ISNUMBER condition is not necessary. The following
should suffice...

=AVERAGE(IF(ROW(A10:A100)=LARGE(IF(ISNUMBER(A10:A 100),IF(A10:A1000,ROW(
A10:A100))),MIN(6,COUNTIF(A10:A100,"0"))),IF(A10: A1000,A10:A100)))

....confirmed with CONTROL+SHIFT+ENTER.

Hope this helps!

In article ,
Domenic wrote:

Try...

=AVERAGE(IF(ROW(A10:A100)=LARGE(IF(ISNUMBER(A10:A 100),IF(A10:A1000,ROW(
A10:A100))),MIN(6,COUNTIF(A10:A100,"0"))),IF(ISNU MBER(A10:A100),IF(A10:A
1000,A10:A100))))

...confirmed with CONTROL+SHIFT+ENTER, not just ENTER.

Hope this helps!


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
Duplicate Range Names by worksheet FlaAl Excel Discussion (Misc queries) 0 May 24th 06 05:14 PM
How do you Identify text as a named range in excel DMDave Excel Discussion (Misc queries) 6 May 7th 06 11:48 PM
Help with using range names in sum function soteman2005 Excel Worksheet Functions 2 November 28th 05 04:43 PM
Array to named range conversion... i-Zapp Excel Discussion (Misc queries) 4 October 25th 05 09:09 PM
Match function...random search? Les Excel Worksheet Functions 10 July 28th 05 11:54 AM


All times are GMT +1. The time now is 09:47 AM.

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"