title: In Libreoffice Calc, which formula will check if a a keyword or part of it is contained in a cell in a row and copy the entire content of that cell?
body: <p>I am learning how to use formulas in spreadsheets, I do use libre office.</p>
  <p>I need to sort out data in a quite huge messy spreadsheet.</p>
  <p>Each column contains mixed data, the sheet is huge, dozens of columns and thousands of rows, if the spreadsheet does not contain errors each cell in a row either contains a different keyword or is empty, there should not be two cells in the same row containing the same keyword.</p>
  <p>The problem to solve is to sort out all the data so to reach to have a new spreadsheet in which each cell marked with a given specific keyword is kept in the same position but placed in one column dedicated to that same keyword.</p>
  <p><em>the kind of spreadsheet with mixed up cells to be sorted out</em></p>
  <p><img src="https://i.stack.imgur.com/HoWUp.jpg" alt="the kind of spreadsheet with mixed up cells to be sorted out" /></p>
  <p><em>the data in the spreadsheet has to be fixed so to appear in this way</em></p>
  <p><img src="https://i.stack.imgur.com/tkASZ.jpg" alt="the data in the spreadsheet has to be fixed so to appear in this way" /></p>
  <p>A formula that can be used to extract sorted out data from a cell is the following:</p>
  <p><code>=IF(SEARCH(&quot;Text1&quot;;B2;1);B2;0)</code></p>
  <p>The formula can be dragged to each cell below to hit the proper cell next to it. The result is correct.</p>
  <p><em>The results are correct, but I do not know why the expected 0 is not printed, there is <strong>#VALUE!</strong> instead</em></p>
  <p><img src="https://i.stack.imgur.com/xJ1NA.jpg" alt="The results are correct, but I do not know why the expected 0 is not printed, there is #VALUE! instead" /></p>
  <p>The logic is very simple, if the cell contains the keyword or any other text that contains that keyword the result is the full content of that cell, otherwise the result is 0.</p>
  <p>Here comes the first question, why do I get #VALUE! as a result for those cells that do not contain the keyword? I expected to get 0 instead, just as indicated in the formula,
  I tried to leave this filed empty and also to put the 0 result in quotes, the actual result is always the same, #VALUE!...</p>
  <p>However, of course this formula extracts only the information contained in one column, so for each other column the process must be repeated.</p>
  <p>In order to avoid to create a column with the formula for each column in the spreadsheet or anyway to process each column one by one and more importantly to have then to merge all the results to form one columns containing only cells with a given keyword I thought to use the same formula extending the parsing to each next cell in the row as follows:</p>
  <p><code>=IF(SEARCH(&quot;text&quot;;B2;1);B2;IF(SEARCH(&quot;text&quot;;C2;1);C2;IF(SEARCH(&quot;text&quot;;D2;1);D2;0)))</code></p>
  <p>The logic is very simple and should output in one go a column containing all the cells containing the keyword that are found in the row, check if the first cell in the row contains a word using the search function, if does then the result is the content of that cell, otherwise perform the next test, the next test is the same, check if the next cell contains a certain word using the search function, if does then the result is the content of that cell, otherwise proceed to the next test…. and so on until last test, if no test gave a true result then print 0 (but we get #VALUE!, OK I could live with that...).</p>
  <p>In theory should work for a any number of cells, but in the practice does not at all, in fact does work only for the first IF test and cell indicated in the formula.</p>
  <p>WHY?</p>
  <p><em>The result using the extended version of the formula to parse N cells in sequence is the same obtained with the simple formula to parse only one cell</em></p>
  <p><img src="https://i.stack.imgur.com/zwN7B.jpg" alt="The result using the extended version of the formula to parse N cells in sequence is the same obtained with the simple formula to parse only one cell" /></p>
  <p>Finally, how do I resolve this problem using IF and Search?</p>
  <p>Is there any other better approach and way to solve this kind of problems and sort out data in huge spreadsheets of this kind?</p>
  <p>Thank you for any hint and help.</p>