Excel - If a word is present turn a number to 0? - excel

I have a simple sheet that adds totals. I need to be able to put the word LD in a cell and have all numbers in that column be read as zero, otherwise they are added as normal.
Example:
B6:B22, C6:C22 have the numbers 10 in them. The totals are added row wise, so the totals for each are 20.
If I put "LD" in B23, I need another formula to read 10 instead of 20.
I was trying to use an IF formula but cannot seem to get anything working.
I apologize if this is unclear, I will do my best to clarify if I need to.
Thank you!

i suggest you get the totals (20) in D6:D22.
So try this formula in D6 and copy it down to D22
=IF(B$23="LD";10;SUM(B6:C6))
Does this help?

If you need the sum of the actual values in the cells, try this (put it in E6 and copy down to E22).
=SUM(IF(EXACT($B$23,"LD"),0,B6),C6)

Related

Is there a way to search a row in Excel to find a number that is between two numbers, and then return that searched number?

I am trying to find a number in a row of numbers that is between 0 and 100. But for my output, I either want a "--" if there is not a number between 0 and 100, or I want the actual numbers that fit with that range.
Here is an example of what I am trying to do: Example
Does anyone know how to solve this issue? I appreciate any help.
Use the logic you have already stated, just work step by step.
I'm assuming you want commas between the numbers, but you can adapt as necessary.
In a row under your input data (I'll assume it starts as B2), put in B3:
=if(and(B2>$B$1),(B2<$C$1),B2,"") and copy across.
Then in the next row in C4: =IF(D3="",C4,C4&D3&",") and copy across.
You either need to amend the formula in the first column, or (my preference) insert a blank column.
You then need to strip the last comma (E.g. =left(P4,len(P4)-1)
And it would be best to name the ranges B1 and C1 rather than just using $formulae.

Extracting other column value based on lookup

I have one large row of data, containing multiple observations. The data consits of:
PO number
Amount
Location
See attached image:
Now what I want is that PO Number 8382 (A2) is looked up in A8:L8 and puts in B2 the amount of each PO number and puts in C2 the location. So what it needs to do, is lookup a value in the row and extract the value on the right of it. I tried H.lookup but that did not work.
Can anyone help me? I used index and match, but I can't make it work. I believe it's probably a simple question but I can't figure it out.
Thank you in advance!
Your thinking is correct.
In cell B2:
=INDEX($A$8:$L$8,1,MATCH($A2,$A$8:$L$8,0)+1)
In cell C2:
=INDEX($A$8:$L$8,1,MATCH($A2,$A$8:$L$8,0)+2)
Copy down.
Try this (It find first occurence in ROW 8)
Cell B2 formula =OFFSET($A$1;1;MATCH($A2;8:8;0);1;1)
Cell C2 formula =OFFSET($A$1;1;MATCH($A2;8:8;0)+1;1;1)
You could use:
=IFERROR(INDIRECT(ADDRESS(8,MATCH(A6,$A$8:$H$8,0)+1)),"PO not found")
using IFERROR you avoid receiving errors if any of the PO not found.

Is it possible to calculate the sum of a whole row?

I have a file that doesn't have a fixed number of columns.
I was wondering if there is a way to tell excel to put the sum of this row in a specific cell, in a way that each time a column is added to the file I don't have to update the formula and increase the range of the sum.
p.s.
I know I can make it a bit easier by just updating the formula like once in 10 times or so. But I was wondering if it's possible to do it once in a lifetime.
Yes sum(1:1) will sum up all values within the first row.
Keep in mind this does not work if the sum needs to be stored in the same row. As you would create a circularity problem.
If your formula will be in b1, and you want to sum from C1 to the end, then simply:
B1: =SUM(C1:XFD1)
Replace XFD with whatever column you think will be far enough to the right that you'll never have to adjust the formula; or leave it as is.
You could make the range dynamic, with something like:
B1: =SUM(OFFSET($A1,0,2,1,LOOKUP(2,1/ISNUMBER(1:1),COLUMN(1:1))-2))
but since that formula is volatile, it may add excessive time to the calculations.
First: Take note of your first cell (Assumed A1)
Second: Take note of your farthest cell (Assumed AZ1)
Then:
=sum(A1:AZ1)

How do I increment just one number in a formula?

How do I increment just one number in a formula?
Here is my formula
=LOOKUP(C1-1,B3:B365,D3:D365).
I want to drag the formula along the row so that just the one number increases by one increment for each cell accross.
So the next cell would read
=LOOKUP(C1-2,B3:B365,D3:D365).
Here is a little abuse that will do what you need:
=LOOKUP($C$1-ROW(1:1),$B$3:$B$365,$D$3:$D$365)
assuming you are dragging down.
If you would drag to the right, you would have to substitute ROW(1:1) by COLUMN(A:A)
You can fix rows like this:
...,B$3:B$365,D$3:D$365
Thanks for all you help guys, but the formula requirements changed, but I managed to find out how to do what I needed to do in the end.
I used another cell reference form the row above the formula to increment the part of the formula that required it.
I needed to develop it further though so that the #N/A's were ignored.
The formula eneded up as --->
=IFERROR(LOOKUP($C$1-B371,$B$3:$B$365,$D$3:$D$365),"")
Thanks for all your suggestions though. I find these support communities veru useful and will use them a lot more often in the future.

Getting the last non-empty cell in a row

I am having a lot of difficulty trying to come up with a way to 'parse' and 'order' my excel spreadsheet. What I essentially need to do is get the last non empty cell from every row and cut / paste it a new column.
I was wondering if there is an easy way to do this?
I appreciate any advice. Many thanks in advance!
Are your values numeric or text (or possibly both)?
For numbers get last value with this formula in Z2
=LOOKUP(9.99E+307,A2:Y2)
or for text....
=LOOKUP("zzz",A2:Y2)
or for either...
=LOOKUP(2,1/(A2:Y2<>""),A2:Y2)
all the formulas work whether you have blanks in the data or not......
Okay, from what you've given if I understood correctly, you can use this formula in cell J1 and drag it down for the other rows below this cell:
=INDEX(A1:I1,1,COUNTA(A1:I1))
This assumes that the 'longest row' goes up to the column I.
You can also use OFFSET. You don't need to specify an ending column, you can just reference the entire row.
=OFFSET(1:1,0,COUNTA(1:1)-1,1,1)

Resources