Formula to grab the first non-zero value in a row of data, and then every value after that.

SanFelippo

Board Regular
Joined
Apr 4, 2017
Messages
124
Hello,

So I will try and explain this as easily as I can using an example. Lets say I have this data in 3 rows:

0 0 0 0 0 0 5 8 0 9 4 1 5
0 0 0 0 1 5 6 7 9 0 0 0 1
0 0 0 0 0 0 0 0 0 0 0 7 9

The formula I would need would return the following results in 3 other rows below what is seen above:

5 8 0 9 4 1 5
1 5 6 7 9 0 0 0 1
7 9

I haven't had any luck so far with this, so any help would be appreciated.
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

Excel 2010
ABCDEFGHIJKLM
10000005809415
20000156790001
30000000000079
4
55809415#REF !#REF !#REF !#REF !#REF !#REF !
6156790001#REF !#REF !#REF !#REF !
779#REF !#REF !#REF !#REF !#REF !#REF !#REF !#REF !#REF !#REF !#REF !
Sheet6
Cell Formulas
RangeFormula
A5{=INDEX($A1:$M1,MATCH(TRUE,$A1:$M1<>0,0)+COLUMN(A1)-1)}
Press CTRL+SHIFT+ENTER to enter array formulas.


Add an iferror to replace the #REF ! with ""s or F5(Goto)-errors to highlight then delete

I think textjoin works too if you have a later Excel version
 
Last edited:
Upvote 0
It can be done without the need for an array or an exact match if your example is a true reflection of your real data.

This will work with positive numbers only, it could be adjusted to work with negatives if needed.

=IFERROR(INDEX($A1:$M1,MATCH(1E-100,$A1:$M1)+COLUMNS($A5:A5)),"")

If your data contains a mixture of positive and negative values then you would need to use the array formula suggested originally.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,952
Messages
6,175,596
Members
452,658
Latest member
GStorm

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