finding first non-zero entry in a row

ljvb

New Member
Joined
Jul 1, 2002
Messages
22
I'm trying to select out the first (left-most) non-zero entry in a row. Any ideas on a formula for this?
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
On 2002-07-02 12:30, ljvb wrote:
I'm trying to select out the first (left-most) non-zero entry in a row. Any ideas on a formula for this?


Array-enter:

=OFFSET(A2,0,MIN(IF(2:2>0,COLUMN(2:2)))-1,1,)

to get the left-most non-zero value in row 2.

Again, array-enter:

=MIN(IF(2:2>0,COLUMN(2:2)))

to get the column number of the left-most cell housing a non-zero value in row 2.
 
Upvote 0
Aladin, thanks for the post. This is clost but doesn't work because the if statement puts zeros in if the logical statement is false, which defeats the purpose of trying to select the zeroes out. I slightly modified what you sent to change the if statement to put a large number in if the logical statement is false (i.e. zero values) and that seems to work. I also changed the >0 to <>0 because I was looking for non zero entries.

=OFFSET(A2,0,MIN(IF(2:2<>0,COLUMN(2:2),EXP(100)))-1,1,)

Thanks.
 
Upvote 0
On 2002-07-03 02:16, ljvb wrote:
Aladin, thanks for the post. This is clost but doesn't work because the if statement puts zeros in if the logical statement is false, which defeats the purpose of trying to select the zeroes out. I slightly modified what you sent to change the if statement to put a large number in if the logical statement is false (i.e. zero values) and that seems to work. I also changed the >0 to <>0 because I was looking for non zero entries.

=OFFSET(A2,0,MIN(IF(2:2<>0,COLUMN(2:2),EXP(100)))-1,1,)

Thanks.

My fault. I forgot to include neg values.

You can also keep the original by changing it to:

=OFFSET(A2,0,MIN(IF(2:2,COLUMN(2:2)))-1,1,)

The IF(2:2 bit means: anything non-zero in 2:2 evaluates to TRUE, otherwise FALSE.

Aladin
 
Upvote 0

Forum statistics

Threads
1,214,832
Messages
6,121,845
Members
449,051
Latest member
excelquestion515

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top