Text functions
FINDB
Matches all 6 recorded answers
Recorded: 6 workbook cells. How we measure this · See the Rust code
Local names in 40 languages
| Language | Name in Excel |
|---|---|
| Arabic | FINDB |
| Bulgarian | FINDB |
| Czech | FINDB |
| Danish | FINDB |
| German | FINDENB |
| Greek | FINDB |
| English (Australia) | FINDB |
| English (United Kingdom) | FINDB |
| English (United States) | FINDB |
| Spanish | ENCONTRARB |
| Estonian | FINDB |
| Finnish | ETSIB |
| French | TROUVERB |
| Hebrew | FINDB |
| Croatian | FINDB |
| Hungarian | SZÖVEG.TALÁL2 |
| Indonesian | FINDB |
| Italian | TROVA.B |
| Japanese | FINDB |
| Korean | FINDB |
| Lithuanian | FINDB |
| Latvian | FINDB |
| Norwegian | FINNB |
| Dutch | VIND.ALLES.B. |
| Polish | ZNAJDŹB |
| Portuguese (Brazil) | PROCURARB |
| Portuguese (Portugal) | LOCALIZARB |
| Romanian | FINDB |
| Russian | НАЙТИБ |
| Slovak | FINDB |
| Slovenian | FINDB |
| Serbian (Latin) | FINDB |
| Swedish | HITTAB |
| Thai | FINDB |
| Turkish | BULB |
| Ukrainian | FINDB |
| Vietnamese | FINDB |
| Chinese (Simplified) | FINDB |
| Chinese (Hong Kong) | FINDB |
| Chinese (Traditional) | FINDB |
Names from Microsoft's support site.
What it does
FINDB(find_text, within_text, [start_num])
FINDB locates one text string inside another and returns the starting position of the first
occurrence, exactly as FIND does — but the position is counted in bytes
rather than in characters. It is case sensitive and does not allow wildcards, on the same terms
as FIND.
Microsoft's article states the distinction more precisely than any other article in the
byte-variant set, and this page quotes its content rather than reconstructing it: FIND is
intended for use with languages that use the single-byte character set (SBCS), whereas
FINDB is intended for languages that use the double-byte character set (DBCS). FIND
always counts each character, whether single-byte or double-byte, as 1, no matter what the
default language setting is. FINDB counts each double-byte character as 2 when you have
enabled the editing of a language that supports DBCS and then set it as the default language.
That last clause is the part worth reading twice, because it makes FINDB's answer depend on
three things rather than one:
- the text — how many of its characters are double-byte under the host encoding;
- the host's enabled editing languages;
- which of them is set as the default language.
Change none of the text and only the third, and the same formula returns a different number.
This is the sharpest statement in Microsoft's documentation that the byte variants are
environment-dependent functions, and it is why the Handbook publishes FINDB as a separate
entry rather than as a note on FIND. (Seven published rows document a byte-variant pair this
way; splitting all seven is the whole of the difference between 534 published Excel rows and
541 Handbook entries.)
Two consequences follow directly. When the DBCS condition is not met, FINDB counts every
character as 1 and its results coincide with FIND's — so an all-ASCII or Western-host test
suite cannot distinguish the two functions at all. And when it is met, a returned byte position
is not a valid character position: feeding a FINDB result into MID rather than MIDB is
a byte/character unit error that produces plausible wrong answers rather than errors.
The article text retrieved for this page states the DBCS condition in terms of enabled and default editing languages, and does not, in that text, enumerate which languages support DBCS. This page therefore does not name them.
Arguments
find_text — required, the text you want to find.
within_text — required, the text containing the text you want to find.
start_num — optional, the character at which to start the search; the first character in
within_text is character number 1, and omitting it is documented as assuming 1. Note that the
article's argument description speaks of characters for this argument while the returned
position is in bytes for FINDB; whether start_num is interpreted in bytes or characters
under the DBCS condition is a real question that the retrieved text does not resolve.
As with FIND, the needle comes first. FINDB(within, needle) is a silent bug.
Try it
Quirks
Result and edge cases
The return kind is Number.
- A
start_numor a result can fall inside a character. This is the byte-variant hazard with no character-variant analogue: byte position 2 of a string beginning with a double-byte character is the second half of that character. WhatFINDBdoes when a match would begin there, and what it does whenstart_numnames such a position, is undefined by every source this page can cite. - Under the non-DBCS condition the function coincides with
FIND, per the article's own statement. - Astral characters have no natural DBCS byte length at all, and the Compatibility Version feature that Microsoft documents for surrogate handling elsewhere in the text family has no stated interaction with byte counting.
Errors
#VALUE!whenfind_textdoes not appear inwithin_text— stated in the article for both members of the pair.- Microsoft publishes a dedicated article on correcting
#VALUE!inFIND/FINDBandSEARCH/SEARCHB. - Whether an out-of-range or mid-character
start_numerrors, and with which code, is not stated in the retrieved text. - Error inputs propagate, and a value kind with no text conversion surfaces
#VALUE!under the shared coercion rules (chapter 02).
How to implement
Notes for implementers
- Do not implement
FINDBasFIND. They coincide only under the non-DBCS condition, and aliasing them ships that specialisation. Say so if that is what you are shipping. - The DBCS condition is host state, not text state. An implementation faithful to the documentation needs the enabled-languages and default-language settings as inputs, which makes this function's observation context wider than an Excel build and a platform.
- Byte positions and character positions must not be interchanged internally, or the bug the function exists to avoid reappears inside the implementation.
- Write down the mid-character rules for both
start_numand the returned position.
Rust code
Show the CalcFunc source of this function
Quoted from the public repository DnaCalc/DnaCalc, crates calc-func and calc-fml, at commit 9e1884369a67. Comments are the source's own. A kernel shared with other functions appears once, on its module page.
FINDB · 1 lines · calc-func/src/catalogue/text_functions.rs on GitHub21 findb_fn "FINDB" (2, 3) [V "find_text", V "within_text", V "start_num"] |s, a, sv| { single_byte(s)?; find(s, a, true) }
Kernels shared with other functions
count_surrogate_pairscatalogue/text_functionssingle_bytecatalogue/text_functionsstartcatalogue/text_functionsfindcatalogue/text_functionstextported/text_kernelsunit_widthported/text_kernelscharacter_boundaryported/text_kernelsslice_character_countported/text_kernelscharacter_scan_endported/text_kernelslen_character_countported/text_kernelstruncatedported/text_kernelspositiveported/text_kernelsfindported/text_kernels
Argument and result plumbing
No implementation has been published with a Handbook test suite for this function.
Version differences
No comparison between specific Excel builds is recorded here yet. This does not establish that all builds behave alike.
Alternatives
Relationships
FINDis the character-counting partner, documented in the same article. It is the function to use unless you specifically need byte offsets.SEARCHBis the case-insensitive, wildcard-aware byte variant —FINDBis toSEARCHBasFINDis toSEARCH.LEFTB,RIGHTB,MIDB,LENB,REPLACEBare the rest of the byte-variant family, and are the functions aFINDBresult must be fed into for the units to agree. Note that theLEFTandLENarticles now mark their byte variants deprecated and no longer state the DBCS mechanism at all; this article still does, which makes it the best surviving documentation of what byte counting means anywhere in the family.ASCandDBCSconvert between half-width and full-width forms.
Named variants
No named variants are recorded yet.
Suggest a correction or contribute an implementation · For agents