Using Logical Operators - All of th results are True, but they shouldnt be

clrichert

New Member
Joined
Sep 4, 2017
Messages
4
Hello Everyone,

I have spent way too much time trying to figure this out, lol...and I appreciate in advance for any and all help you can provide.
I am using this formula [=IF(A2>0,"MPY","")] to give me either a blank, or the text "MPY". The issue is that cell "A2" also has a formula. The results are always "TRUE" even when the cell returns no value. Is there a work-around for this issue?

Thanks again!

A2 Begins at 1.00
FebruaryMarchAprilMayJuneJuly
1.00MPY0.36MPY-MPY-MPY0.14MPY0.36MPY
<colgroup><col width="73" style="width: 55pt; mso-width-source: userset; mso-width-alt: 2669;"> <col width="68" style="width: 51pt; mso-width-source: userset; mso-width-alt: 2486;" span="11"> <tbody> </tbody>

This is the formula to get my number:
IF(ISERROR(VLOOKUP('All-in-One'!$A$3,Coupon_Table,6,0)),"",IF(LEN(VLOOKUP('All-in-One'!$A$3,Coupon_Table,6,0))=0,"-",VLOOKUP('All-in-One'!$A$3,Coupon_Table,6,0)))
This is the formula to get my text:
IF(A2>0,"MPY","")
The months that have returned with a "-" have no data to return, it is only there to make it easier to read the table.
I would like for the "MPY" to populate only when a value has been returned to the left of its cell.
As is stands now, it will always populate. I understand why, the order of text value vs. numerical value, but how to get around this issue is beyond me.

<tbody>
</tbody><colgroup><col></colgroup>

<tbody>
</tbody><colgroup><col><col span="12"></colgroup>

Hopefully I have explained this adequately. Thank again!
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Sorry everyone, I didn't realiaze that the font show up like that...here it is in black.

FebruaryMarchAprilMayJuneJuly
1.00MPY0.36MPY-MPY-MPY0.14MPY0.36MPY
<colgroup><col width="99" style="width: 74pt; mso-width-source: userset; mso-width-alt: 3620;"> <col width="68" style="width: 51pt; mso-width-source: userset; mso-width-alt: 2486;" span="11"> <tbody> </tbody>
 
Upvote 0
To Excel, a text value is greater than a number value... since your dash is a text value, it is considered greater than 0. Maybe this formula will work for you...

If all numbers are always greater than 0...
=IF(ISTEXT(A2),"MPY")

If number can be negative, zero or positive...
=IF(ISTEXT(A2),"",IF(A2>0,"MPY",""))
 
Last edited:
Upvote 0
I think leelnich's response in the crossposted thread is best:

=IF(N(A2)>0, "MPY", "")
I would agree, although that gave me an idea (not sure why) for a completely different approach (only one function call instead of two)...

=TEXT(A2,"\MP\Y;;;")
 
Last edited:
Upvote 0
joeu2004, Rick (and indirectly, leelnich) - NEAT !

Rick - I understand basically how your solution works - essentially it's number formating - but what is the function of the " \ " characters ?
Is it to prevent interpretation of the values as Months / Years ?
 
Last edited:
Upvote 0
Rick - I understand basically how your solution works - essentially it's number formating - but what is the function of the " \ " characters ?
Is it to prevent interpretation of the values as Months / Years ?
Yes, exactly. You have two choices for embedding text into the format pattern argument... quote the text (which in a VB text string means you use two quote marks on each side of the text) or backslash the individual meta-characters that the TEXT function uses for its own purposes. If you have a lot of text, then (double-double) quote it, with only two meta-characters, I find it easier (and shorter) to backslash them. Way, way back in my UNIX days, working with Regular Expressions, the backslash (when used to remove the special meaning of a meta-character) was called the "escape character"... I am not sure if that term is still used or not.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,098
Messages
6,128,812
Members
449,468
Latest member
AGreen17

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