libreoffice VLOOKUP if cell includes value in text
Assistant
User
SEARCH
Assistant
Sure! Here’s a concise explanation and example of how to use SEARCH in LibreOffice Calc to find if a cell includes a certain value/text string:
What does SEARCH do?
SEARCH(find_text; within_text; [start]) searches for the string find_text inside within_text.
Returns the position number where the substring starts, e.g., 1 if it's at the beginning.
Returns an error (#VALUE!) if find_text is not found.
SEARCH is case-insensitive. If you need case-sensitive, use FIND.
Example formula to check if a cell contains a substring
plaintext
=ISNUMBER(SEARCH("apple"; A1))
User
=SEARCH(A1,Sheet1.F1:F$100)
Assistant
You wrote:
plaintext
=SEARCH(A1,$Sheet1.$F$1:$F$100)
This formula attempts to search for the text in cell A1 inside the range $Sheet1.$F$1:$F$100.
Important points:
SEARCH does NOT work with ranges like $F$1:$F$100 and return multiple results.
In LibreOffice Calc, the standard VLOOKUP function works by matching the lookup value exactly (or based on a sorted range for approximate matches), but it does not natively support searching for a text substring within a cell.
If you want to perform a lookup where the key is contained inside the text of a cell (i.e., substring match), VLOOKUP alone won't handle this directly.
Goal:
You want to do a lookup like: "Find the row in a range where the cell contains the lookup text as part of the string."
Solutions / Workarounds
1. Use an Array Formula with SEARCH or FIND
You can combine INDEX and MATCH with a criteria that finds which cells contain your lookup text.
Example:
Suppose your data is in range A2:B10, and you want to find the value in column B where column A includes the lookup text.
Important: This is an array formula, so you must press Ctrl + Shift + Enter after typing it (in older versions of LibreOffice Calc). In newer versions, it might auto-calculate as an array formula.
Explanation:
SEARCH(D1; A2:A10) looks for the text in D1 inside each cell of A2:A10.
ISNUMBER(...) returns TRUE where the substring is found, FALSE otherwise.
MATCH(TRUE; ... ; 0) finds the position of the first TRUE, i.e., where substring occurs.
INDEX(B2:B10; ...) returns the corresponding value from column B.
2. Using Helper Column
If you want to avoid array formulas, add a helper column that flags if the substring is found:
In column C:
plaintext
=ISNUMBER(SEARCH($D$1; A2))
Copy down.
Then use:
plaintext
=VLOOKUP(TRUE; C2:B10; 2; 0)
But since VLOOKUP requires the key in the leftmost column, you might need to adjust the data setup, e.g., helper column first:
C (helper)
A (text)
B (result)
TRUE/FALSE
text
output
Then:
plaintext
=VLOOKUP(TRUE; C2:B10; 3; 0)
Make sure the helper column is first in the range.
Summary
VLOOKUP does not support substring match by itself.
Use INDEX/MATCH with ISNUMBER(SEARCH(...)) as an array formula to find partial matches.
Alternatively, create a helper column indicating substring presence, and use VLOOKUP on that.
If you want me to write a specific formula based on your exact situation, just share your data layout!
Returns TRUE if "apple" is found anywhere in cell A1 (not case sensitive)
Returns FALSE otherwise.
Using SEARCH inside VLOOKUP-type logic (substring match)
You can combine SEARCH with INDEX and MATCH to find a row where a substring exists.
Assume:
You want to look up the value in D1 inside column A (A2:A10), and return corresponding info from B2:B10.