Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 325
Default Returning the row no of the lowest non-zero cell in a range

Good morning all,

Can anyone suggest a quick way of returning the row number of the lowest
cell in a range (e.g. B10:B25) that contains a non-zero value? I thought of a
nested loop where the value of each cell is tested and the row number stored
is to a varable if it is greater than the value already stored there, but
this needs to be part of a worksheet_change macro and it might slow things
down too much doing things in this way.

Thanks in advance

Pete


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Returning the row no of the lowest non-zero cell in a range

Two steps:

1. determine the lowest non-zero number: =SMALL(B10:B25,1) and if this is
zero use =SMALL(B10:B25,2)

2. find the row: use MATCH() on the result of step 1
--
Gary's Student


"Peter Rooney" wrote:

Good morning all,

Can anyone suggest a quick way of returning the row number of the lowest
cell in a range (e.g. B10:B25) that contains a non-zero value? I thought of a
nested loop where the value of each cell is tested and the row number stored
is to a varable if it is greater than the value already stored there, but
this needs to be part of a worksheet_change macro and it might slow things
down too much doing things in this way.

Thanks in advance

Pete


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Returning the row no of the lowest non-zero cell in a range

Pete,

Use

=MATCH(MIN(IF(B10:B25<0,B10:B25)),B10:B25,0)

which is an array formula, so commit with Ctrl-Shift-Enter. Be aware, it
will find the first if there are duplicates.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Peter Rooney" wrote in message
...
Good morning all,

Can anyone suggest a quick way of returning the row number of the lowest
cell in a range (e.g. B10:B25) that contains a non-zero value? I thought

of a
nested loop where the value of each cell is tested and the row number

stored
is to a varable if it is greater than the value already stored there, but
this needs to be part of a worksheet_change macro and it might slow things
down too much doing things in this way.

Thanks in advance

Pete




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 325
Default Returning the row no of the lowest non-zero cell in a range

Sorry, I didn't make myself clear.

The purpose of the exercise is to determine how far down a worksheet a
"Cumulative Hours" formula needs to be copied, so I don't have a column
containing unnecessary identical cumulative values where there isn't a
corresponding actual (the X axis, actuals and cumulatives are in columns B, C
and D)
I'm trying to do this in VBA - not in the actual worksheet.
Sorry if I wasted your time before!

Pete





"Gary''s Student" wrote:

Two steps:

1. determine the lowest non-zero number: =SMALL(B10:B25,1) and if this is
zero use =SMALL(B10:B25,2)

2. find the row: use MATCH() on the result of step 1
--
Gary's Student


"Peter Rooney" wrote:

Good morning all,

Can anyone suggest a quick way of returning the row number of the lowest
cell in a range (e.g. B10:B25) that contains a non-zero value? I thought of a
nested loop where the value of each cell is tested and the row number stored
is to a varable if it is greater than the value already stored there, but
this needs to be part of a worksheet_change macro and it might slow things
down too much doing things in this way.

Thanks in advance

Pete


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 325
Default Returning the row no of the lowest non-zero cell in a range

Bob,

Sorry, I didn't make myself clear.

The purpose of the exercise is to determine how far down a worksheet a
"Cumulative Hours" formula needs to be copied, so I don't have a column
containing unnecessary identical cumulative values where there isn't a
corresponding actual (the X axis, actuals and cumulatives are in columns B, C
and D)
I'm trying to do this in VBA - not in the actual worksheet.
Sorry if I wasted your time before!

Pete


"Bob Phillips" wrote:

Pete,

Use

=MATCH(MIN(IF(B10:B25<0,B10:B25)),B10:B25,0)

which is an array formula, so commit with Ctrl-Shift-Enter. Be aware, it
will find the first if there are duplicates.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Peter Rooney" wrote in message
...
Good morning all,

Can anyone suggest a quick way of returning the row number of the lowest
cell in a range (e.g. B10:B25) that contains a non-zero value? I thought

of a
nested loop where the value of each cell is tested and the row number

stored
is to a varable if it is greater than the value already stored there, but
this needs to be part of a worksheet_change macro and it might slow things
down too much doing things in this way.

Thanks in advance

Pete







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 325
Default Returning the row no of the lowest non-zero cell in a range

Sorry, I didn't make myself clear.

The purpose of the exercise is to determine how far down a worksheet a
"Cumulative Hours" formula needs to be copied, so I don't have a column
containing unnecessary identical cumulative values where there isn't a
corresponding actual (the X axis, actuals and cumulatives are in columns B, C
and D)
I'm trying to do this in VBA - not in the actual worksheet.
Sorry if I wasted your time before!

Pete


"Gary''s Student" wrote:

Two steps:

1. determine the lowest non-zero number: =SMALL(B10:B25,1) and if this is
zero use =SMALL(B10:B25,2)

2. find the row: use MATCH() on the result of step 1
--
Gary's Student


"Peter Rooney" wrote:

Good morning all,

Can anyone suggest a quick way of returning the row number of the lowest
cell in a range (e.g. B10:B25) that contains a non-zero value? I thought of a
nested loop where the value of each cell is tested and the row number stored
is to a varable if it is greater than the value already stored there, but
this needs to be part of a worksheet_change macro and it might slow things
down too much doing things in this way.

Thanks in advance

Pete


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Returning the row no of the lowest non-zero cell in a range


iRow = Evaluate("MATCH(MIN(IF(B10:B25<0,B10:B25)),B10:B2 5,0)")

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Peter Rooney" wrote in message
...
Bob,

Sorry, I didn't make myself clear.

The purpose of the exercise is to determine how far down a worksheet a
"Cumulative Hours" formula needs to be copied, so I don't have a column
containing unnecessary identical cumulative values where there isn't a
corresponding actual (the X axis, actuals and cumulatives are in columns

B, C
and D)
I'm trying to do this in VBA - not in the actual worksheet.
Sorry if I wasted your time before!

Pete


"Bob Phillips" wrote:

Pete,

Use

=MATCH(MIN(IF(B10:B25<0,B10:B25)),B10:B25,0)

which is an array formula, so commit with Ctrl-Shift-Enter. Be aware, it
will find the first if there are duplicates.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Peter Rooney" wrote in message
...
Good morning all,

Can anyone suggest a quick way of returning the row number of the

lowest
cell in a range (e.g. B10:B25) that contains a non-zero value? I

thought
of a
nested loop where the value of each cell is tested and the row number

stored
is to a varable if it is greater than the value already stored there,

but
this needs to be part of a worksheet_change macro and it might slow

things
down too much doing things in this way.

Thanks in advance

Pete







  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Returning the row no of the lowest non-zero cell in a range

Sub MinRow()
Dim rng As Range
Dim MyRow As Long
Dim MyFormula As String

Set rng = Sheet1.Range("B10:B25")
MyFormula = WorksheetFunction.Match(WorksheetFunction.Small _
(rng, WorksheetFunction.CountIf(rng, 0) + 1), rng, 0)
MyRow = MyFormula + 9
End Sub

Mike F
"Peter Rooney" wrote in message
...
Good morning all,

Can anyone suggest a quick way of returning the row number of the lowest
cell in a range (e.g. B10:B25) that contains a non-zero value? I thought
of a
nested loop where the value of each cell is tested and the row number
stored
is to a varable if it is greater than the value already stored there, but
this needs to be part of a worksheet_change macro and it might slow things
down too much doing things in this way.

Thanks in advance

Pete




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
Question about returning some values from highest to lowest Cory from Eugene[_2_] Excel Discussion (Misc queries) 3 February 21st 08 06:39 PM
Looking up a named range and returning value into a cell Maggie[_4_] Excel Discussion (Misc queries) 3 October 25th 07 02:59 PM
looking for another same value cell in a range and returning a coresponding value dawid72 Excel Worksheet Functions 4 June 9th 06 08:35 PM
Range vs. lowest #, 2nd lowest #, 3rd lowest #, etc jwebb Excel Discussion (Misc queries) 2 March 9th 05 12:38 PM
How can I get the lowest price, second lowest etc. from a range o. Robin Excel Worksheet Functions 2 November 9th 04 12:23 PM


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