Skip to content

Allow VLOOKUP over IF array tables#1677

Open
JfanLiu wants to merge 2 commits into
handsontable:developfrom
JfanLiu:fix/vlookup-if-array-table
Open

Allow VLOOKUP over IF array tables#1677
JfanLiu wants to merge 2 commits into
handsontable:developfrom
JfanLiu:fix/vlookup-if-array-table

Conversation

@JfanLiu
Copy link
Copy Markdown

@JfanLiu JfanLiu commented May 20, 2026

Context

VLOOKUP and HLOOKUP should accept lookup tables produced by formulas, not only tables backed by a cell range.

For example, Microsoft Excel evaluates this formula to 200:

=VLOOKUP(BF109,IF({1,0},BD109:BD112,AV109:AV112),2,0)

HyperFormula previously returned #VALUE! because lookup validation rejected array-backed SimpleRangeValues.

How did you test your changes?

  • Added a smoke regression test for VLOOKUP over an IF-constructed array table.
  • Ran npm run test:jest -- smoke.
  • Ran npm run verify:typings.
  • Ran npm run lint.

Related issues:

N/A

Checklist:

  • I have reviewed the guidelines about Contributing to HyperFormula and I confirm that my code follows the code style of this project.
  • I have signed the Contributor License Agreement.
  • My change is compliant with the OpenDocument standard.
  • My change is compatible with Microsoft Excel.
  • My change is compatible with Google Sheets.
  • I described my changes in the CHANGELOG.md file.
  • My changes require a documentation update.
  • My changes require a migration guide.

Note

Medium Risk
Changes evaluation/vectorization behavior of IF and relaxes VLOOKUP/HLOOKUP validation to accept ad-hoc (formula-produced) ranges, which could affect array semantics and error cases for these core functions.

Overview
Lookup functions now accept formula-produced array tables (e.g. IF(...) returning an ad-hoc SimpleRangeValue) instead of rejecting them with #VALUE!, by removing the requirement that the lookup table be backed by a concrete cell range and validating index against rangeValue dimensions.

IF is updated to vectorize when its condition evaluates to a multi-element ad-hoc range, enabling formulas like =VLOOKUP(key,IF({1,0},rangeA,rangeB),...) to produce a usable lookup table. A smoke regression test and changelog entry were added for this behavior.

Reviewed by Cursor Bugbot for commit 349df04. Bugbot is set up for automated code reviews on this repo. Configure here.

Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@netlify
Copy link
Copy Markdown

netlify Bot commented May 20, 2026

Deploy Preview for hyperformula-dev-docs ready!

Name Link
🔨 Latest commit 349df04
🔍 Latest deploy log https://app.netlify.com/projects/hyperformula-dev-docs/deploys/6a0dbf923a8cb80008ba9ae0
😎 Deploy Preview https://deploy-preview-1677--hyperformula-dev-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link
Copy Markdown

netlify Bot commented May 20, 2026

Deploy Preview for hyperformula-docs ready!

Name Link
🔨 Latest commit 349df04
🔍 Latest deploy log https://app.netlify.com/projects/hyperformula-docs/deploys/6a0dbf924ea48f0008e339c5
😎 Deploy Preview https://deploy-preview-1677--hyperformula-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@JfanLiu JfanLiu changed the title Fix/vlookup if array table Allow VLOOKUP over IF array tables May 20, 2026
@JfanLiu JfanLiu force-pushed the fix/vlookup-if-array-table branch from ad1405b to 349df04 Compare May 20, 2026 14:05
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 349df04. Configure here.

return new CellError(ErrorType.VALUE, ErrorMessage.LessThanOne)
}

if (index > range.width()) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lookup accepts scalar table

Low Severity

Removing the range === undefined guard lets VLOOKUP and HLOOKUP run on 1×1 ad-hoc tables from coerceToRange when the second argument is a scalar. Excel returns #VALUE! for a non-table lookup range; these formulas may return a value instead.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 349df04. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant