Skip to content

#2383 - Fixed issue where VLOOKUP and HLOOKUP sometimes returned wrong value on unsorted data.#2384

Open
swmal wants to merge 1 commit into
develop8from
bug/sc1054
Open

#2383 - Fixed issue where VLOOKUP and HLOOKUP sometimes returned wrong value on unsorted data.#2384
swmal wants to merge 1 commit into
develop8from
bug/sc1054

Conversation

@swmal

@swmal swmal commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes incorrect results from VLOOKUP and HLOOKUP with approximate match (range_lookup = TRUE or omitted).

Problem

The approximate-match binary search ran over a value-trimmed range with all blank cells removed (GetRangeInfoByValue + GetLookupRange). This shifted the search midpoints relative to Excel, producing wrong values (sometimes 0) — especially on unsorted data or ranges containing blank cells.

Fix

Added SearchAscFullRange, which searches the range while only skipping leading blanks (kept performant for whole-column references via the value edge). Inner/trailing blanks retain their positions, matching Excel's partitioning. VLOOKUP and HLOOKUP now use this path.

@swmal swmal added the bug Something isn't working label Jun 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant