Přejít k hlavnímu obsahu

Jak vyhledat první nenulovou hodnotu a vrátit odpovídající záhlaví sloupce v aplikaci Excel?

Předpokládejme, že máte řadu dat, nyní chcete vrátit záhlaví sloupce v tomto řádku, kde dojde k první nenulové hodnotě, jak je znázorněno na následujícím obrázku obrazovky, tento článek, představím vám užitečný vzorec pro řešení tohoto úkolu v aplikaci Excel.

vyhledávání dokumentů první nenulové 1

Vyhledejte první nenulovou hodnotu a vraťte odpovídající záhlaví sloupce se vzorcem


šipka modrá pravá bublina Vyhledejte první nenulovou hodnotu a vraťte odpovídající záhlaví sloupce se vzorcem

Chcete-li vrátit záhlaví sloupce první nenulové hodnoty v řádku, může vám pomoci následující vzorec, postupujte takto:

Zadejte tento vzorec: =INDEX($B$1:$I$1,MATCH(TRUE,INDEX(B2:I2<>0,),0)) do prázdné buňky, kde chcete najít výsledek, K2například a poté přetáhněte popisovač výplně dolů do buněk, na které chcete použít tento vzorec, a vrátí se všechna odpovídající záhlaví sloupců první nenulové hodnoty, jak ukazuje následující snímek obrazovky:

vyhledávání dokumentů první nenulové 2

Poznámka: Ve výše uvedeném vzorci, B1: I1 je záhlaví sloupců, které chcete vrátit, B2: I2 jsou data řádku, která chcete vyhledat první nenulovou hodnotu.

Nejlepší nástroje pro produktivitu v kanceláři

🤖 Kutools AI asistent: Revoluční analýza dat založená na: Inteligentní provedení   |  Generovat kód  |  Vytvořte vlastní vzorce  |  Analyzujte data a generujte grafy  |  Vyvolejte funkce Kutools...
Populární funkce: Najít, zvýraznit nebo identifikovat duplikáty   |  Odstranit prázdné řádky   |  Kombinujte sloupce nebo buňky bez ztráty dat   |   Kolo bez vzorce ...
Super vyhledávání: Více kritérií VLookup    VLookup s více hodnotami  |   VLookup na více listech   |   Fuzzy vyhledávání ....
Pokročilý rozevírací seznam: Rychle vytvořte rozevírací seznam   |  Závislý rozbalovací seznam   |  Vícenásobný výběr rozevíracího seznamu ....
Správce sloupců: Přidejte konkrétní počet sloupců  |  Přesunout sloupce  |  Přepnout stav viditelnosti skrytých sloupců  |  Porovnejte rozsahy a sloupce ...
Doporučené funkce: Zaměření mřížky   |  Návrhové zobrazení   |   Velký Formula Bar    Správce sešitů a listů   |  Knihovna zdrojů (Automatický text)   |  Výběr data   |  Zkombinujte pracovní listy   |  Šifrovat/dešifrovat buňky    Odesílat e-maily podle seznamu   |  Super filtr   |   Speciální filtr (filtr tučné/kurzíva/přeškrtnuté...) ...
Top 15 sad nástrojů12 Text Tools (doplnit text, Odebrat znaky, ...)   |   50+ Graf Typ nemovitosti (Ganttův diagram, ...)   |   40+ Praktické Vzorce (Vypočítejte věk na základě narozenin, ...)   |   19 Vložení Tools (Vložte QR kód, Vložit obrázek z cesty, ...)   |   12 Konverze Tools (Čísla na slova, Přepočet měny, ...)   |   7 Sloučit a rozdělit Tools (Pokročilé kombinování řádků, Rozdělit buňky, ...)   |   ... a více

Rozšiřte své dovednosti Excel pomocí Kutools pro Excel a zažijte efektivitu jako nikdy předtím. Kutools for Excel nabízí více než 300 pokročilých funkcí pro zvýšení produktivity a úsporu času.  Kliknutím sem získáte funkci, kterou nejvíce potřebujete...

Popis


Office Tab přináší do Office rozhraní s kartami a usnadňuje vám práci

  • Povolte úpravy a čtení na kartách ve Wordu, Excelu, PowerPointu, Publisher, Access, Visio a Project.
  • Otevřete a vytvořte více dokumentů na nových kartách ve stejném okně, nikoli v nových oknech.
  • Zvyšuje vaši produktivitu o 50%a snižuje stovky kliknutí myší každý den!
Comments (15)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hello, my problem is: a have value 1,2,3,4,...50 that are the number of month. How to denormalize month into real datum. Thank you in advance a lot!!!
This comment was minimized by the moderator on the site
Does anyone know what you would do if your cell that contains a zero has a formula in it? When I use this formula, I end up with whatever the first column header is regardless of whether it is zero or not.
This comment was minimized by the moderator on the site
E como faço pra procurar o primeiro valor diferente de zero da esquerda pra direita?
This comment was minimized by the moderator on the site
Hello, Matheus
If you want to return the first non-zero value from a row, please apply the below formula:
=INDEX(B2:F2,MATCH(TRUE,INDEX(B2:F2<>0,),0))
Please have a try, hope it can help you!
This comment was minimized by the moderator on the site
What if you needed the last non-zero value in an array?

P.S. This was really helpful, thank you so much!
This comment was minimized by the moderator on the site
Hello, Ali,
To get the column header based on the last non-zero value, please apply the below formula, see screenshot:
=INDEX($B$1:$H$1,MAX((COLUMN(B2:H2)-MIN(COLUMN(B2:H2))+1)*(B2:H2<>0)))
Please remember to press Ctrl+Shift+Enter key together.
https://www.extendoffice.com/images/stories/comments/comment-skyyang/doc-last-non-zero.png
Please try, hope it can help you!
This comment was minimized by the moderator on the site
The formula is super helpful and helped me sorted out the situation! Thanks!!! Is there any chance you may please help to also explain how it works?
This comment was minimized by the moderator on the site
How do you look up for the second,third and fourth non-zero value?
This comment was minimized by the moderator on the site
Hello, Robert,
To lookup the second, third or fourth non-zero values and return their columns, please apply the below formula: (After pasting the formula, please press Ctr + Shift + Enter keys together.)
=INDEX($B$1:$I$1,SMALL(IF(B2:I2<>0, COLUMN(B2:I2)-COLUMN(A2)),2))


Note: To extract the third or fourth result, you just need to change the number 2 to 3,4 as you need.

Please have a try, hope it can help you!
This comment was minimized by the moderator on the site
CAN U EXPLIAN HOW THIS FORMULA WORKS
This comment was minimized by the moderator on the site
Hello Priya,I am glad to help. I will separate the formula = INDEX($B$1:$I$1,MATCH(TRUE,INDEX(B2:I2<>0,),0)) into 3 parts, and explain the formula to you step by step.
First, let us see the inner-most formula =INDEX(B2:I2<>0,). This formula returns an array of TRUE and FALSE whether the values of range B2:I2 are equal to 0. Please see the screenshot 1, formula =INDEX(B2:I2<>0,) returns {FALSE,FALSE,FALSE,FALSE,TRUE,TRUE,TRUE,TRUE}.
Second, =MATCH(TRUE,INDEX(B2:I2<>0,),0) =MATCH(TRUE, {FALSE,FALSE,FALSE,FALSE,TRUE,TRUE,TRUE,TRUE}, 0). It returns the position of the first value "TRUE", while 0 in the formula means an exact match. We can see that the first value "TRUE" occurs at the 5th position of the array. Then the second formula returns 5. See the screenshot 2.
Finally,  =INDEX(B1:I1,MATCH(TRUE,INDEX(B2:I2<>0,),0))=INDEX(B1:I1,5). It returns the 5th value of the array B1:I1. We can see in the screenshot that the value is "May". So the final formula returns "May". 
PS: To drag the fill handle down the formula to get the rest of the results, we must make the range B1:I1 absolute. So we add $ to range B1:I1 to keep it absolute. 
Hope my explanation can solve your puzzle. Have a nice day.
Sincerely,Mandy
This comment was minimized by the moderator on the site
Thank you Mandy for illustrating it in detail.
Kindly guide how to get the last non zero value from same formula instead of first non zero value.
Will Match work for that or not?
This comment was minimized by the moderator on the site
Hi MandyZhou,

Thank you for the explanation!
I have a follow-up question.
How would the formula change if you had to look up the year too?
So in the above example, let's assume that column J is 'Year' and that in cell J2 is written '2015'.
And in cell K2 I would need the column header for the first non-zero value of the year in L2 (year 2015, so I would need to find 'Jun' in cell K2).

Thanks in advance for your help!
Jason
This comment was minimized by the moderator on the site
How can I return the second and third, etc non zero value? Your formula is amazing but I am trying to search more keywords from a text so sometimes they are 2 or 3 in the same sentence
This comment was minimized by the moderator on the site
se volessi "l'ultimo" Valore Diverso Da Zero E Restituire L'intestazione Della Colonna Corrispondente Con La Formula?
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations