Solved

How do I get the retrieved value changed automatically to either a plus or a minus in Excel 2007?

Posted on 2016-09-30
20
48 Views
Last Modified: 2016-11-07
I have this formula for retrieving a value:

=Index(Travbanor!A6:A100;Match(C1;Travbanor!B6:B100;0))

The retrieve value might be a minus value, a 0 or a plus value. If a minus value or a plus value the minus/plus should be reverted to the opposite, if a zero nothing should happen.
0
Comment
Question by:hermesalpha
  • 12
  • 6
  • 2
20 Comments
 
LVL 25

Expert Comment

by:ProfessorJimJam
ID: 41823374
use this

=(Index(Travbanor!A6:A100;Match(C1;Travbanor!B6:B100;0)))*-1
0
 

Author Comment

by:hermesalpha
ID: 41823441
I use a vlookup function instead, so I wonder in which position I should place your *-1 in this formula?:

=IFERROR(VLOOKUP(C12;Travbanor!B6:L100;11;FALSE);"")
0
 

Author Comment

by:hermesalpha
ID: 41823443
Also, can I have the zero written out if a zero is found?
0
 
LVL 25

Assisted Solution

by:ProfessorJimJam
ProfessorJimJam earned 85 total points
ID: 41823449
wrap the entire formula inside to parenthesis and then multiply by minus one -1

like this =(IFERROR(VLOOKUP(C12;Travbanor!B6:L100;11;FALSE);""))*-1
0
 
LVL 32

Expert Comment

by:Rob Henson
ID: 41823458
I would say the *-1 has to be within the VLOOKUP or you risk multiplying "" by -1.

=(IFERROR(VLOOKUP(C12;Travbanor!B6:L100;11;FALSE)*-1;""))

Or put the minus in front of the VLOOKUP:

=IFERROR(-VLOOKUP(C12;Travbanor!B6:L100;11;FALSE);"")

Minusing a negative number gives positive, and vice versa. Minus 0 is still zero.
0
 

Author Comment

by:hermesalpha
ID: 41823666
Thanks, that worked when I put the *-1 within the VLOOKUP.

Is there any way to format this cell only so it always displays a zero?
0
 
LVL 32

Expert Comment

by:Rob Henson
ID: 41823681
To display 0 no matter the actual value is possible with custom format:

"0";"0";"0";"0"

But why would you want to do that?
0
 

Author Comment

by:hermesalpha
ID: 41823687
I mean, if there is no minus value and no plus value to retrieve but there is a "0" (not empty cell, but "0" is written in it), then I want this value also to be retrieved (not only minus or plus value to be retrieved).
0
 
LVL 32

Expert Comment

by:Rob Henson
ID: 41823698
If the VLOOKUP result is zero or blank then the result of the formula will be zero. The IFERROR part of above formula will put blank when the lookup value is not found. If you want zero in that instance change the "" at the end to 0
0
 

Author Comment

by:hermesalpha
ID: 41866535
I tried now adding a "0" at the end (where the "" where). But nothing is displayed in the cell when the value to retrieve is "0".
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 32

Expert Comment

by:Rob Henson
ID: 41866668
Can you copy your actual formula here to look at?
0
 

Author Comment

by:hermesalpha
ID: 41866670
This is my current formula:

=(IFERROR(VLOOKUP(C12;Travbanor!B6:L100;11;FALSE)*-1;0))

I don't want to turn on global displaying of zeros as I'm not sure the zeros should be displayed everywhere. Is there any way to format a single cell to display zeros?
0
 
LVL 32

Expert Comment

by:Rob Henson
ID: 41866679
If you put the 0 in quotes it will be text so will still show even with global hiding of zeros.
0
 

Author Comment

by:hermesalpha
ID: 41867149
I tried now, but same as before, no zero is displayed:

=(IFERROR(VLOOKUP(C12;Travbanor!B6:L100;11;FALSE)*-1;"0"))

But what if I delete the "IFERROR"?
0
 
LVL 32

Accepted Solution

by:
Rob Henson earned 415 total points
ID: 41868354
The IFERROR covers the scenario when value in C12 is not found in range Travbanor!B6:B100 (first column of lookup range). Without the IFERROR you will get #N/A error.

If the value in C12 is found and the result from column 11 is blank or zero then the result will be zero which will be hidden by the suppression of zeros. If you still want these zeros to show then you will have to allow for it in the formula:

=IFERROR(IF(VLOOKUP(C12;Travbanor!B6:L100;11;FALSE)=0;"0";VLOOKUP(C12;Travbanor!B6:L100;11;FALSE));"0")

This says if the result of the lookup is zero put "0" otherwise put the result; if the result is an error then put "0".
0
 

Author Comment

by:hermesalpha
ID: 41876913
It almost worked now, zero is dislayed when it should. But I need to put the *-1 somewhere to have the minus/plus switched.
0
 

Author Comment

by:hermesalpha
ID: 41876916
This worked, now I get the minus/plus switched also:

=IFERROR(IF(VLOOKUP(C12;Travbanor!B6:L100;11;FALSE)*-1=0;"0";VLOOKUP(C12;Travbanor!B6:L100;11;FALSE))*-1;"0")
0
 

Author Comment

by:hermesalpha
ID: 41876917
No, my second change adding the *-1 in two places did not work, because I do not get the zero displayed then.
0
 

Author Comment

by:hermesalpha
ID: 41876931
This worked, now I get zero displayed and also switched minus/plus:

=IFERROR(IF(VLOOKUP(C12;Travbanor!B6:L100;11;FALSE)=0;"0";VLOOKUP(C12;Travbanor!B6:L100;11;FALSE)*-1);"0")
0
 

Author Closing Comment

by:hermesalpha
ID: 41876936
Thanks for the solution, works fine now.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now