Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 75
Default Last Value Greater than Zero in a column

In a column of 121 numbers which can be positive or negative or zero, is
there a function to find the last positive value in the column?

Or do I need to build a UDF?
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,268
Default Last Value Greater than Zero in a column

A couple of ways

=LOOKUP(2,1/(A1:A100),A1:A10)

entered normally or


=INDEX(A1:A10,MAX((A1:A100)*(ROW(A1:A10))))


entered with ctrl + shift & enter


note that if there is a text string in the range at the right spot it will
be returned since text is greater than number according to Excel



--


Regards,


Peo Sjoblom


"Dkline" wrote in message
...
In a column of 121 numbers which can be positive or negative or zero, is
there a function to find the last positive value in the column?

Or do I need to build a UDF?



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,572
Default Last Value Greater than Zero in a column

Why not just add Isnumber to eliminate a text return:

=INDEX(A1:A25,MAX((A1:A250)*(ISNUMBER(A1:A25))*(R OW(A1:A25))))

?
--
Regards,

RD

---------------------------------------------------------------------------
Please keep all correspondence within the NewsGroup, so all may benefit !
---------------------------------------------------------------------------
"Peo Sjoblom" wrote in message
...
A couple of ways

=LOOKUP(2,1/(A1:A100),A1:A10)

entered normally or


=INDEX(A1:A10,MAX((A1:A100)*(ROW(A1:A10))))


entered with ctrl + shift & enter


note that if there is a text string in the range at the right spot it will
be returned since text is greater than number according to Excel



--


Regards,


Peo Sjoblom


"Dkline" wrote in message
...
In a column of 121 numbers which can be positive or negative or zero, is
there a function to find the last positive value in the column?

Or do I need to build a UDF?





  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 75
Default Last Value Greater than Zero in a column

I ended up creating a User Defined Function.

Dim rngPremium As Range
Dim wb As Workbook
Dim ws As Worksheet
Dim intLastPremiumYear As Integer 'last premium year
Const cintColNumber As Integer = 7 'column number - 7 is usual
Const cintColStartRow As Integer = 3 'start row of column - 3 is usual
Const cintColLastRow As Integer = 123 'start row of column - 123 is usual
Dim intCount As Integer
Sub GetLastPremium()
intCount = 0
Set wb = ThisWorkbook
Set ws = wb.Worksheets("GUI")
Set rngPremium = ws.Range(Cells(cintColNumber, cintColStartRow),
Cells(cintColNumber, cintColLastRow))
For i = cintColLastRow To cintColStartRow Step -1
intCount = intCount + 1
If Cells(i, cintColNumber) 0 Then
intLastPremiumYear = 121 - intCount + 1
ws.Range("LastPremiumYear") = intLastPremiumYear
Exit Sub
End If
Next i
Set rngPremium = Nothing
Set ws = Nothing
Set wb = Nothing
End Sub

"RagDyer" wrote:

Why not just add Isnumber to eliminate a text return:

=INDEX(A1:A25,MAX((A1:A250)*(ISNUMBER(A1:A25))*(R OW(A1:A25))))

?
--
Regards,

RD

---------------------------------------------------------------------------
Please keep all correspondence within the NewsGroup, so all may benefit !
---------------------------------------------------------------------------
"Peo Sjoblom" wrote in message
...
A couple of ways

=LOOKUP(2,1/(A1:A100),A1:A10)

entered normally or


=INDEX(A1:A10,MAX((A1:A100)*(ROW(A1:A10))))


entered with ctrl + shift & enter


note that if there is a text string in the range at the right spot it will
be returned since text is greater than number according to Excel



--


Regards,


Peo Sjoblom


"Dkline" wrote in message
...
In a column of 121 numbers which can be positive or negative or zero, is
there a function to find the last positive value in the column?

Or do I need to build a UDF?






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
How to average a column of numbers that are greater than 0? JimNColorado Excel Worksheet Functions 13 December 11th 07 01:22 AM
Greater than less than total in a column cream puff Excel Discussion (Misc queries) 1 October 8th 07 09:54 PM
Sum values greater than x and less than y in a column Rookie_User Excel Discussion (Misc queries) 1 July 20th 07 05:19 PM
How do I search an array for values in a column greater than zero letsagmj Excel Worksheet Functions 0 July 26th 06 02:41 AM
Adding a column based on greater than a date Toni G. Excel Worksheet Functions 4 March 17th 05 08:06 PM


All times are GMT +1. The time now is 09:29 PM.

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"