Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
wilby31
 
Posts: n/a
Default Locating Last Nonzero Cell in a Row


I need to locate the last nonzero term in a row. The rows consist of
zeros and ones.

For instance:

__ A B C D E F
1| 1 1 1 0 0 3
2| 1 0 1 0 1 5
3| 0 1 0 1 1 5

As you can see in column F, I have my desired results (the number of
the column of the last 1). I have tried incorporating SUM and COUNTIF
functions to place where the last 1 would be in a row with a known
size, but I can't figure out how to account for the 0's that are
located within the first and the last 1.

Any ideas? This has plagued me for a couple days now.

Thanks,
Brent


--
wilby31
------------------------------------------------------------------------
wilby31's Profile: http://www.excelforum.com/member.php...o&userid=27287
View this thread: http://www.excelforum.com/showthread...hreadid=467919

  #2   Report Post  
Biff
 
Posts: n/a
Default

Hi!

One way:

Entered as an array using the key combo of CTRL,SHIFT,ENTER:

=MAX(IF(A1:E10,COLUMN(A1:E1)))

Biff

"wilby31" wrote in
message ...

I need to locate the last nonzero term in a row. The rows consist of
zeros and ones.

For instance:

__ A B C D E F
1| 1 1 1 0 0 3
2| 1 0 1 0 1 5
3| 0 1 0 1 1 5

As you can see in column F, I have my desired results (the number of
the column of the last 1). I have tried incorporating SUM and COUNTIF
functions to place where the last 1 would be in a row with a known
size, but I can't figure out how to account for the 0's that are
located within the first and the last 1.

Any ideas? This has plagued me for a couple days now.

Thanks,
Brent


--
wilby31
------------------------------------------------------------------------
wilby31's Profile:
http://www.excelforum.com/member.php...o&userid=27287
View this thread: http://www.excelforum.com/showthread...hreadid=467919



  #3   Report Post  
Domenic
 
Posts: n/a
Default

Try...

F1, copied down:

=LOOKUP(2,1/(A1:E1=1),COLUMN(A1:E1)-COLUMN(A1)+1)

....confirmed with just ENTER, or...

=MATCH(2,1/(A1:E1=1))

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

Hope this helps!

In article ,
wilby31 wrote:

I need to locate the last nonzero term in a row. The rows consist of
zeros and ones.

For instance:

__ A B C D E F
1| 1 1 1 0 0 3
2| 1 0 1 0 1 5
3| 0 1 0 1 1 5

As you can see in column F, I have my desired results (the number of
the column of the last 1). I have tried incorporating SUM and COUNTIF
functions to place where the last 1 would be in a row with a known
size, but I can't figure out how to account for the 0's that are
located within the first and the last 1.

Any ideas? This has plagued me for a couple days now.

Thanks,
Brent

  #4   Report Post  
Bruno Campanini
 
Posts: n/a
Default

"wilby31" wrote in
message ...

I need to locate the last nonzero term in a row. The rows consist of
zeros and ones.

For instance:

__ A B C D E F
1| 1 1 1 0 0 3
2| 1 0 1 0 1 5
3| 0 1 0 1 1 5

As you can see in column F, I have my desired results (the number of
the column of the last 1). I have tried incorporating SUM and COUNTIF
functions to place where the last 1 would be in a row with a known
size, but I can't figure out how to account for the 0's that are
located within the first and the last 1.

Any ideas? This has plagued me for a couple days now.


Another alternative:

{=MAX(OFFSET(A1,,,1,5)*COLUMN(A1:E1))}
FormulaArray

Bruno


  #5   Report Post  
Harlan Grove
 
Posts: n/a
Default

Bruno Campanini wrote...
....
Another alternative:

{=MAX(OFFSET(A1,,,1,5)*COLUMN(A1:E1))}
FormulaArray


Never use volatile functions (like OFFSET) unnecessarily. Biff's
similar array formula,

=MAX(IF(A1:E10,COLUMN(A1:E1)))

is preferable. Further, there's NEVER a good reason to use OFFSET with
constant 2nd through 5th arguments. Simple cell references would always
be preferable for clarity as well as efficiency.



  #6   Report Post  
Bruno Campanini
 
Posts: n/a
Default

"wilby31" wrote in
message ...

I need to locate the last nonzero term in a row. The rows consist of
zeros and ones.

For instance:

__ A B C D E F
1| 1 1 1 0 0 3
2| 1 0 1 0 1 5
3| 0 1 0 1 1 5

As you can see in column F, I have my desired results (the number of
the column of the last 1). I have tried incorporating SUM and COUNTIF
functions to place where the last 1 would be in a row with a known
size, but I can't figure out how to account for the 0's that are
located within the first and the last 1.

Any ideas? This has plagued me for a couple days now.


Another alternative:

{=MAX(OFFSET(A1,,,1,5)*COLUMN(A1:E1))}
FormulaArray

Bruno


  #7   Report Post  
wilby31
 
Posts: n/a
Default


Thanks everyone! Those are all great suggestions! You saved me from a
severe migrane. :)


--
wilby31
------------------------------------------------------------------------
wilby31's Profile: http://www.excelforum.com/member.php...o&userid=27287
View this thread: http://www.excelforum.com/showthread...hreadid=467919

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
Cell color based upon cell value My View Excel Discussion (Misc queries) 11 July 6th 05 03:59 AM
cell color index comparison MINAL ZUNKE New Users to Excel 1 June 30th 05 07:11 AM
Cell Change Color - Need Help alani New Users to Excel 3 June 29th 05 03:50 PM
Function syntax to compare cell contents ES Excel Worksheet Functions 2 May 18th 05 03:53 PM
VLookup resulting in a blank cell... KempensBoerke Excel Worksheet Functions 1 October 28th 04 09:57 PM


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