If X is greater than Y in a cell

Mr2017

Well-known Member
Joined
Nov 28, 2016
Messages
644
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi

I've got three formulae that work in isolation, but not together.

If the text "4 for 10" is in cell A1, I'd like one formula that returns the text "Multi deal where X<Y" if 4 is greater than 10, which it is. But returns "Multi deal where X>Y"if the text in cell A2 was 10 for 4.

The formulae which work in isolation are as follows:

This formula in cell B1 returns the word "for" if that text is in A1:

=IF(ISNUMBER(SEARCH("for",A1)),"For","")

This formula returns the first number on the left of A1 (if it has the word "for")

=RIGHT(TRIM(LEFT(A1,SEARCH("for",A1)-1)),2)

This formula returns the number on the right of the cell (if it has the word "for")

=TRIM(RIGHT(SUBSTITUTE(A1," ",REPT(" ",100)),100))

But when I combine them together, I get an error message.

Eg this should return "Multi deal where X <Y" but it doesn't (if this formula is in cell D1). Does anyone know the solution, please?

=IF(and((ISNUMBER(SEARCH("for",A1)),"For",RIGHT(TRIM(LEFT(A1,SEARCH("for",A1)-1)),2)>TRIM(RIGHT(SUBSTITUTE(A1," ",REPT(" ",100)),100))),"Multi Deal where X>Y",IF(and((ISNUMBER(SEARCH("for",A1)),"For",RIGHT(TRIM(LEFT(A1,SEARCH("for",A1)-1)),2)<TRIM(RIGHT(SUBSTITUTE(A1," ",REPT(" ",100)),100))),"Multi Deal where X<Y",""))))
 
Yeah!!

Thanks!!

Adding +0 worked!!

I think I may have added the the +0 one bracket too early, previously, but I tested out what you said above in a different place, and it worked!

Thanks again! That's a massive help!
 
Upvote 0

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

Forum statistics

Threads
1,214,788
Messages
6,121,577
Members
449,039
Latest member
Arbind kumar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top