If cell is 0, move to next row

jlea94

New Member
Joined
Aug 27, 2015
Messages
4
I'm listing 50 rows x 8 columns of cells (defined 'allhazards')

However each cell in myhazards is referencing other sheets and contain 0's where there is no text to be referenced. When I list myhazards in a single column using this formula:

=INDEX(allhazards,1+INT((ROW($A1)-1)/COLUMNS(allhazards)),MOD(ROW($A1)-1+COLUMNS(allhazards),COLUMNS(allhazards))+1)

How do I implement this:

if cell in 'allhazards' is 0, do not reference this, move to next row
...then reference next row's columns until cell is 0, then move to next row
...keep doing this until there are no rows left to be referenced


eg. if 'allhazards' contained these cells (2 rows x 8 columns):
hello how are 0 0 0 0 0
good 0 0 0 0 0 0 0

It should produce this:
hello
how
are
good

but not this:
hello
how
are
0
0
0
0
0
good
0
0
0
0
0
0
0


Cross-posted here: http://www.excelforum.com/excel-programming-vba-macros/1103028-if-cell-is-0-index-next-row.html
 
Last edited by a moderator:
My suggestion would be to keep the results with zeroes as helper column and the final result with the following array formula, confirm with Ctrl+Shift+Enter, not just Enter, assuming the interim results are in $A$4:$A$19 (adjust as applicable), in B4:
Code:
=IFERROR(INDEX($A$4:$A$19,SMALL(IF($A$4:$A$19<>0,ROW($A$4:$A$19)-ROW($A$4)+1),ROWS(A$4:A4))),"")
and copy down.
 
Upvote 0

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