Need help with writing an Excel formula

MargieA 40 Reputation points
2026-09-01T15:23:18.7+00:00

User's image

Columns A and B represent a range. Trying to write a formula that will look up the amount in Column F, to where it falls between (or equal to) A and B, and return the % from Column C into Column G.

Microsoft 365 and Office | Excel | For business | Windows

Answer accepted by question author
Jay1 Tran 600 Reputation points Independent Advisor
2026-09-01T15:46:42.3366667+00:00

Hi MargieA,

Thank you for reaching out.

From what you've shared, the formula provided by the AI is correct. However, each value in Column A contains a trailing hyphen (-), which causes Excel to treat the values as text rather than numbers. As a result, the formula will fail when attempting to compare the value in Column F against the ranges in Columns A and B.

To make the formula work, please remove the trailing hyphens from Column A. If you need to keep the hyphens, please reach out again, and I’ll be happy to help modify the formula accordingly.

Thank you for your time and patience.

Was this answer helpful?

2 people found this answer helpful.

Answer accepted by question author

AI answer

2026-09-01T15:23:34.24+00:00

In G2, use a range-match formula like this:

=XLOOKUP(1,((F2>=$A$2:$A$100)*(F2<=$B$2:$B$100)),$C$2:$C$100)

Then fill the formula down column G.

How it works:

  • F2>=$A$2:$A$100 checks whether the value in F2 is greater than or equal to the start of each range.
  • F2<=$B$2:$B$100 checks whether it is less than or equal to the end of each range.
  • Multiplying those two tests returns 1 only for the row where F2 falls within the range.
  • XLOOKUP returns the matching percentage from column C.

If the value in F2 might not match any range, use:

=IFERROR(XLOOKUP(1,((F2>=$A$2:$A$100)*(F2<=$B$2:$B$100)),$C$2:$C$100),"")

An equivalent alternative is:

=FILTER($C$2:$C$100,(F2>=$A$2:$A$100)*(F2<=$B$2:$B$100),"")

AI-generated content may be incorrect. Read our transparency notes for more information.

Was this answer helpful?

2 people found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. MargieA 40 Reputation points
    2026-09-01T16:52:56.7033333+00:00

    Accepted

    Thanks!

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.