Hledání dat - Excel tipy

Některé otázky, které přicházejí, jsou docela obtížné. Dnes máme sloupec buněk. Každá buňka má několik slov, poté datum a další slova. Cílem je vytáhnout část data tohoto textu do nového sloupce. Toto je soubojová epizoda s nápady od Billa a Mika.

Sledovat video

  • Billův super široký přístup:
  • Všech 12 měsíců vložte do samostatných sloupců
  • Pomocí funkce HLEDAT zjistíte, zda je tento měsíc v původním textu
  • Chcete-li zjistit minimální výchozí pozici, použijte = AGGREGATE (5,6,…
  • Několik dalších vzorců, které hledají před měsícem číslo 2 nebo 3 pozice
  • Mikeův přístup:
  • Místo HLEDAT použijte SEARCH. Najít rozlišuje velká a malá písmena, vyhledávání nikoli.
  • Vytvořte operaci pole funkce argumentu zadáním B13: B24 jako Find_Text.
  • Vzorec vrátí #HODNOTA! Chyba, ale pokud stisknete F2, F9, uvidíte, že vrací pole.
  • Prvních 13 funkcí v AGGREGATE nemůže zpracovat pole, ale funkce 14-19 mohou zpracovat pole.
  • 5 = MIN a 15 = SMALL (, 1) jsou podobné, ale SMALL (, 1) bude pracovat s polem.
  • LOOKUP, SUMPRODUCT, CHISQ.TEST, INDEX a AGGREGATE mohou zpracovávat argumenty funkčních polí bez Ctrl + Shift + Enter
  • Mike byl chytřejší, když zkoumal, zda jsou 2 znaky před začátkem číslo, a poté popadl 3 znaky předtím. Extra prostor je eliminován TRIM ()
  • Chcete-li získat nadpis, použijte funkci SUBSTITUTE, abyste se zbavili textu Datum ve sloupci C.

Přepis videa

Bill Jelen: Hej, vítej zpět. Je čas na další podcast Dueling Excel. Jsem Bill Jelen. Přidá se ke mně Mike Girvin z aplikace Excel Is Fun.

Toto je náš Duel # 170: Hledání dat

Ahoj, vítejte zpět všichni. Měl jsem tu tak velkou otázku a nemohl jsem ji vyřešit. Přinejmenším jsem to nemohl snadno vyřešit, tak jsem šel za Mikem Girvinem a řekl jsem: „Miku, hej, máš způsob, jak to udělat?“ Řekl: „Ano, mám způsob, jak to udělat. Pojďme udělat duel. “

Někdo na YouTube tedy odeslal tyto údaje a každá buňka obecně má něco jako název dokumentu následovaný datem. Chtěli rozdělit tato data do názvu dokumentu: co to je, co se děje a pak jaké je datum. Ale data jsou úplně zlá. Stejně jako tady je 20. ledna; ale tady dole jsou věci, kde může být datum po buňce, 9. dubna. Dobře, a bez ohledu na to, jakým způsobem je, chceme to najít. A někdy jsou tu dvě rande a to je prostě úplně hrozné a že je to taková jen smíšená situace v rande a jak je to možné, neměli byste mít ani rande, dobře. Tady je můj pokus. Na pravou stranu dám věci, které hledám. Co se mi opravdu líbí, je, že nikdy nezkracovali název měsíce. Já opravdu,opravdu si toho vážím. Napište tedy leden a já se sem takhle přetáhnu do prosince a pro každou buňku, kterou chci vědět, můžeme najít = FIND ten leden. Takže stisknu F4 jednou, dvakrát, abych to uzamkl jen na řádek, v textu tam ve sloupci A, takhle. Jednou, dvakrát, třikrát stisknu klávesu F4, abych ji uzamkl na sloup, dobře. A tady nám říká, že leden se nachází v pozici 32 a dalších 11 měsíců nám řekne, že se vůbec nenachází. Jinými slovy, nyní dostáváme chybu hodnoty. To, co tam musím udělat, je, že musím najít, musím najít minimální hodnotu ignorující všechny chyby hodnot. Takže zde odkryjte tento malý vzorec = AGGREGATE a pojďme to vytvořit úplně od začátku, = AGGREGATE, to, co chceme, je MIN, takže to je číslo 5,a pak Ignorujte chybové hodnoty čárka 6 a poté všechny tyto buňky od ledna do prosince. A to, co nám řeknete, bude to, že nám řeknete, kde se měsíc stane. A v tomto případě dostaneme 0, řekněme, že měsíc se vůbec nestane.

Dobře, pojďme odkrýt zbytek. Abych zvládl situaci, kdy tu máme 20. ledna nebo 1. listopadu, řekl jsem, že první věc, kterou udělám, je podívat se na to, kde ten měsíc začíná, a vrátit se o dvě buňky, dvě buňky, dva znaky , dva znaky. A podívejte se, jestli je to číslo, ne tak. Tady se jmenuje můj sloupek, Adjust2. Upravit2. A tady budeme dělat. Řeknu, vezměte MID A2 a začněte to tam, kde v G2-2 na délku 1, přidejte 0 a zeptejte se, je to číslo nebo ne? Dobře, tak to je číslo. A potom se také podíváme na situaci, kdy se jedná o dvouciferné datum, tedy 20. ledna. Takže tomu se říká Adjust3, vraťte se o 3 znaky zpět odkud. Takže je tu Kde, vraťte se o tři znaky o délce 1, přidejte k tomu 0 a podívejte se, jestli to ječíslo, dobře? Pak se přizpůsobíme a Upravené kde říká IF. KDYŽ je tento podivný případ 0, dáme jen opravdu velkou hodnotu 999; jinak půjdeme z G2 a buď se vrátíme zpět 3, pokud je Adjust3 True, nebo se vrátíme 2, pokud je Adjust2 True, nebo pokud žádný z nich není True, Kde bude tam, kde začíná měsíc. Dobře, teď, když víme, že to Upravené kde, to dvakrát zkopírujeme dolů. No, hej, teď je to opravdu snadné. Jen se chystáme - u titulu řekneme, že vezmeme nalevo od A2, kolik znaků chceme. Chceme D2-1, protože to je -1 je zbavit se prostoru na konci. Ačkoli si myslím, že se TRIM také na konci zbaví prostoru.KDYŽ je to tento podivný případ 0, dáme jen opravdu velkou hodnotu 999; jinak půjdeme z G2 a buď se vrátíme zpět 3, pokud je Adjust3 True, nebo se vrátíme 2, pokud je Adjust2 True, nebo pokud žádný z nich není True, Kde bude tam, kde začíná měsíc. Dobře, teď, když víme, že to Upravené kde, to dvojitým kliknutím zkopírujeme dolů. No, hej, teď je to opravdu snadné. Jen se chystáme - u titulu řekneme, že vezmeme nalevo od A2, kolik znaků chceme. Chceme D2-1, protože to je -1 je zbavit se prostoru na konci. Ačkoli si myslím, že se TRIM také na konci zbaví prostoru.KDYŽ je to tento podivný případ 0, dáme jen opravdu velkou hodnotu 999; jinak půjdeme z G2 a buď se vrátíme zpět 3, pokud je Adjust3 True, nebo se vrátíme 2, pokud je Adjust2 True, nebo pokud žádný z nich není True, Kde bude tam, kde začíná měsíc. Dobře, teď, když víme, že to Upravené kde, to dvakrát zkopírujeme dolů. No, hej, teď je to opravdu snadné. Jen se chystáme - u titulu řekneme, že vezmeme nalevo od A2, kolik znaků chceme. Chceme D2-1, protože to je -1 je zbavit se prostoru na konci. Ačkoli si myslím, že se TRIM také na konci zbaví prostoru.nebo pokud nic z toho není pravda, Kde bude tam, kde začíná měsíc. Dobře, teď, když víme, že to Upravené kde, to dvojitým kliknutím zkopírujeme dolů. No, hej, teď je to opravdu snadné. Jen se chystáme - u titulu řekneme, že vezmeme nalevo od A2, kolik znaků chceme. Chceme D2-1, protože to je -1 je zbavit se prostoru na konci. Ačkoli si myslím, že se TRIM také na konci zbaví prostoru.nebo pokud nic z toho není pravda, Kde bude tam, kde začíná měsíc. Dobře, teď, když víme, že to Upravené kde, to dvakrát zkopírujeme dolů. No, hej, teď je to opravdu snadné. Jen se chystáme - u titulu řekneme, že vezmeme nalevo od A2, kolik znaků chceme. Chceme D2-1, protože to je -1 je zbavit se prostoru na konci. Ačkoli si myslím, že se TRIM také na konci zbaví prostoru.s -1 je zbavit se mezery na konci. Ačkoli si myslím, že se TRIM také na konci zbaví prostoru.s -1 je zbavit se mezery na konci. Ačkoli si myslím, že se TRIM také na konci zbaví prostoru.

A pak k datu použijeme MID. MID for- MID of A2 počínaje Upraveným kde v D2 a jděte ven 50 nebo cokoli jiného, ​​o čem si myslíte, že by to mohlo být, a pak funkci TRIM a my to dvakrát zkopírujeme dolů.

Dobře, důvod, proč jsem oslovil Mika, je ten, že jsem řekl: Zajímalo by mě, jestli existuje způsob, jak bych mohl nahradit těchto 12 sloupců jediným formulářem, vlastně těchto 13 sloupců jediným formulářem. Existuje nějaký způsob, jak to udělat pomocí vzorce Array? A Mike samozřejmě napsal tuto skvělou knihu Ctrl + Shift + Enter na maticové vzorce. A zkusil jsem několik různých věcí a v mé mysli neexistoval způsob, jak by to bylo možné. Dobře, ale víte, pojďme se zeptat odborníka. Takže Mike, podívejme se, co máš.

Mike Girvin: Thanks,. Hey, and speaking of expert, this was pretty expertly done. You used FIND, AGGREGATE, ISNUMBER(MID. Now, when you sent this question over to me, I went ahead and solved it and it is amazing how similar my solution is to yours.

Alright, I'm going to go over to this sheet here. I'm going to start with figuring out where the start position in this text string is for each particular month. Now the way I'm going to do it is I'm going to, hey, use this SEARCH function. Now, you used FIND, I use SEARCH. Actually probably FIND is better in this situation because FIND is case-sensitive, SEARCH is not. Now normally what we do with either FIND or SEARCH, I say, hey, go FIND, January, comma within this larger text string, that's how we normally use SEARCH Ctrl+Enter, and it counts on its finger: one, two, three, four, five. It says the 32nd character is where it found January.

Now, instead of doing it in many cells across the columns, I'm going to hit F2, come up here and the FIND_TEXT. Notice we gave it 1 item, SEARCH gave us 1 answer. But if I highlight the entire column of month names, now instead of a single item I put many items in there. This is a Function Argument. We're putting an array of items in and so that means we're doing a Function Argument Array operation. Any time you do that, you tell the function, hey, give me 12 answers, 1 for each month. Now this will deliver an array so if I try to Enter this and copy down it's not going to work.

Well, let's go down to any particular cell, F2 and then F9 to look that yes, in fact, it is delivering an array, and look at that. It looks like I F2 up here, forgot to lock it. So I'm going to click on that and F4, Ctrl+Enter, double click and send it down, F2, F9. There we go, that's that array. There's exactly 12 answers and there's the 34 and the 55. Now, from this array, since we always want the actual first month, not the second month, we want whatever the MIN is because those are number of characters in from the left. So I'm going to click Escape, come up to the top F2. I'm going to use the AGGREGATE function. Hey, we would like to use AGGREGATE 5 but no matter how hard you try if you have an array operation and we do here, if you try to put any function 1 to 13, it just doesn't work. But no problem, we have SMALL, so number 15 comma. Any one of those functions 14 to 19, they understand array operations. And once you select 14 or above, this is the screen tip you're working off, not this bottom one with the references. Alright, comma.

The second options here we want to Ignore errors, comma. That number 6 will then tell AGGREGATE to look through here and ignore the errors. It will only see the numbers. And this is one of five functions in Excel: LOOKUP some product, CHI SQUARE TEST, AGGREGATE, and INDEX that actually have a special argument that can handle Array operations without doing any special key stroke. So there is the Array, comma, and then for K we simply put A1. That's our way of getting them in. Close parentheses, Ctrl+Enter, double click and send it down. And so that tells us the position where it found the first month name from this list.

Now, we'll deal with the NUM error at the very end in our final formula. Now, we are going to have to take these and notice that sometimes there's a number before the month and sometimes, like down here in December, there is not. So I'm going to do the same thing did. I'm going to go back two characters and check whether it is a letter or in this case a number =MID, there’s the text, comma, the starting position. Well, I want to start at 32 in this case and -2 to go back to and comma. I get exactly one character. Now, if I close parenthesis MID LEFT RIGHT they all deliver text, double click and send it down and we want to check if it's a number. So watch this, the whole column is highlighted. Active cell at the top, I'm going to hit F2. We could do any Math operation to convert text numbers back to number so I'm going to add 0, Ctrl+Enter to populate this edited formula down through the column. Ctrl+Enter. Now, we can ask the question: Is the returned item a number? F2. So now I say ISNUMBER, close parenthesis, Ctrl+Enter. So now we have a pattern of Trues and Falses. Now, remember we need to get the starting position and for 32 we're definitely going to have to subtract 3 and start at that 20 but notice down here, we don't want to subtract any. So our logical test if I hit F2, that will simply be put into the IF Logical Test Argument. If that comes out True comma then I want to jump back 3 comma. Otherwise I want to jump back 0, close parenthesis, Ctrl+Enter to populate that all the way down. Now we can take this number and subtract the number over here to give us our starting position. Active cell at the top F2, I'm putting this inside of MID. There's the text, comma. And can you believe it? All of this to get the start number. So I'm going to click on that B2 and subtract our IF, come to the end comma and I'm just going to put a big number in here, 100, some big number big enough to get all the way to the end, close parenthesis and Ctrl+Enter to populate that all the way down. It looks like we have some extra spaces and that makes sense because right here we went back three, so no problem. Active cell at the top, F2, I'm going to use the haircut function, the diet function. No, the TRIM function to remove extra spaces except for single spaces between words. Come to the end, close parenthesis, Ctrl+Enter to populate that all the way down.

Now, I have the date, oh, except for the NUM. Now, I could come to the top and use IF error but then it would run all of these plus that cell right there and for a small data set, it doesn't matter at all; but, with the goal of efficiency, I'm going to say IF(ISNUMBER and I'm going to click on that cell, that way close parenthesis, comma. The trigger for whether we run the formula is only based on that instead of the entire formula. If that comes out True, we want to run the formula, comma. Otherwise, double quote double quote. That zero link text string will show nothing. Ctrl+Enter, double click and send it down. And now, all we need to do is get the Title. Well, I already have the text that I don't want in here so I'm going to use the SUBSTITUTE function. SUBSTITUTE, there's the text, comma. The old text, it's that right there, comma, the new text. Hey, I want to take that and SUBSTITUTE in nothing. There's our zero link text string, Ctrl+Enter, double click and send it down.

Now, I'm going to come over here to column B, right click, Hide and there we go. Alright, throw it back to.

Bill Jelen: Hey, Mike, that is brilliant and I know exactly, exactly where I went wrong. Right here in row 12 when the formula returned the #VALUE error, you pressed F2, F9 to see that it's returning an array. When I got the #VALUE error, I just swore a little bit and said, why isn't this working? Never thought of pressing F2, F9, alright. Also, like that, of course, MIN and SMALL(,1) are the same but the difference is SMALL(,1) will work with an array in the AGGREGATE function. That was a beautiful, beautiful trick. And then, I went through that whole hassle to look at 2 characters before and 3 characters before. You were smart enough to say, “Hey, we're going to go 2 characters before and if so, go back 3 characters.” Worst case you get a space for that extra space and eliminated by the TRIM. And then the cherry on top, using SUBSTITUTE function to get rid of the Date text in column C. What a brilliant, brilliant way to go, alright.

Chci tedy všem poděkovat za to, že se zastavili. Uvidíme se příště na další podcast Dueling Excel od a Excel Is Fun.

Stáhnout soubor

Stáhněte si ukázkový soubor zde: Duel180.xlsm

Zajímavé články...