How do I add a condition to my Excel formula? - excel

I would like Excel to execute the following formula ONLY if B2 has a value in it. How do I write that into this formula?
=IF( ISNUMBER( MATCH( MATCH(A2,AllResources4[Title],0), SUBTOTAL(3,OFFSET(AllResources4[[#Headers],[Title]], ROW(AllResources4[Title]) - ROW(AllResources4[[#Headers],[Title]]),))*(ROW(AllResources4[Title]) - ROW(AllResources4[[#Headers],[Title]])),0)), VLOOKUP(A2,AllResources4[#All],8,0),"")
I want Excel to look for A2 in the "AllResources4" table or return the result only if its corresponding B2 cell has a value. Same with A3, A4, etc.

Using ISBLANK is the way to go. However, I sometimes get sketched out since you can't see how ISBLANK is actually working. That being said, it sometimes it worth inserting a column next to your data dedicated to the ISBLANK function. Something like:
=IF(ISBLANK(cell),0,1)
Then, you can check to make sure that the function works and use sort/filter to get the cells that you need to use the function on. Of course, if you want the function applied to all the data but only to work on the non-blank cells, you could add a clause to the IF for whether the column value we jsut made is one or zero.
NOTE* if you are working with numbers, the count function might also be helpful

This worked! =IF(B2=0,"",Formula)

=IF(ISBLANK(B2),Formula,"")
The ISBLANK function will check if a cell is blank (has no value), combined with a if statement will run your formula only when B2 has something in it. The above formula will output nothing if B2 is blank.

Related

Check for specific formula (no VBA)

Is it possible to check if cell formula is a specific formula, and not just "isformula" ?
My example:
In cell A1 I have, normally, "=B2".
But during the use of this sheet the formula might be overwritten to "=D4".
How can I get a simple TRUE result if the formula in cell A1 is "=D4", and FALSE if it's something else ?
I get fix it with VBA but I prefer to use standard formulas first (if it's possible obviously).
Thanks for your time.
Using FORMULATEXT:
=FORMULATEXT(A1)="=D4"

Problem with IF AND and Vlookup nested formula

I am trying to put a nested IF, AND and Vlookup formula. I want formula to return the value "0.17" in cell F3 if cell D3 has text "pasha" and B3 is not equal to cells mentioned in vlookup formula but its returns zero instead of showing 0.1. Please guide, TIA
=IFERROR(IF(AND(D3="Pasha",VLOOKUP(B3,G70:H78,2,0)<>B3),0.17,IF(VLOOKUP(B3,$B$69:$B$89,1,0)=B3,0.15,"")),0)
enter image description here
You may want to replace
VLOOKUP(B3,G70:H78,2,0)<>B3)
(Excel will unsuccessfully try to match B3 value with values from G column range while it contains different type of data:“Pasha”)
with
NOT(ISNUMBER(MATCH(B3,H70:H78,0)))
And feel free to adjust the second VLOOKUP accordingly.
So, how about this:
You need to to sort the vlookup() but the process for testing the conditions is there.

EXCEL: When dragging cells to the right I need to use information stored in columns not rows (Not sure how to ask this properly)

It's probably a simple problem, but I did not even know the keywords to google it ;/. Let's say I have this data :
Now I also have this litle formula:
If I know drag the C cell to the right, Excel will attempt the following caluclation:
=2+B1
What I want him to do is to attempt this calculation
=2+A2
Of course the easiest solution would be to store my initial data in one row instead of 1 column, but it is really inconvenient for me. Thanks for any help
You can use the indirect() method to reference a cell by it's "String identifier", i.e. "A3". When filling out to the right, use CONCATENATE() and COLUMN() to create your String identifiers {A1,A2,A3,A4,A5...} as required:
=2+INDIRECT(CONCATENATE("A";COLUMN()-2))
This will result in the following:
Side-Node: If you want this for some x/y-Grid-Generation, you can also be lazy,
and just insert =COLUMN() for every cell from "A1 - Z1" and ROW() for every cell from "A2 - A24".
(Or even avoid these at all and directly perform your actual calculation by using column() and row() as replacement for your x/y.
You may try using a combination of the INDIRECT and COLUMN functions:
=2+INDIRECT("A"&(COLUMN()-2))
You would paste the above formula into cell C1, and then drag across to the right however many columns/rows you wanted to cover.
This would result in the following:
This works because COLUMN()-2 returns 1 for the C column, 2 for the D column, and so on. Therefore, the formula will be calling INDIRECT on A1, A2, etc. for column C, D, and so on.
In general, if you want relative references to move down as cells are dragged to the right, you can use this:
Instead of:
= 2+A1
Do:
= 2+INDEX($A:$A,COLUMN()+<offset>)
Where <offset> is whatever offset you need. The offset will change depending on which column the starting formula is located in.
INDEX should be preferred over INDIRECT because INDIRECT is volatile (must recalculate after any change to the workbook) but INDEX is not (only recalculated when one of the inputs the formula, in this case $A:$A, changes).

Summing multiple ranges as a conditional statement in Excel

I am trying to avoid using VBA if that's at all possible and I most certainly think that it is!
I'm currently trying to sum up a range if a certain condition is met. My function works when the range is limited and small, but does not work when I encompass my actual desired range. Here is some snippets of code:
=SUMIF(B13:M13,P23, B15:M15)
That function currently sums from B15 to M15 if there are any matches in between B13 and M13 with P23. It works like a charm. If there are discrepancies in between B13 and M13 it will only sum that matches which is exactly what I want it to do.
I want it to cover a much broader range, so I altered my formula as follows:
=SUMIF(B13:M13:B32:M32:B51:M51,P23, B15:M15:B34:M34:B53:M53)
I want it to do the same thing as before. I want it to analyze B13:M13 as well as B32:M32 as well as B51:M51 and compare it to P23. If there are matches I want it to sum B15:M15 as well as B34:M34 as well as B53:M53. If there are non matches, I want them to be omitted as was the case in my previous function.
Can anyone tell me what's wrong with my formula?
Actually, your formula =SUMIF(B13:M13:B32:M32:B51:M51,P23, B15:M15:B34:M34:B53:M53) converts to =SUMIF(B13:M51,P23, B15:M53) (you can check it for example using "Evaluate formula" tool in the "Formulas" Ribbon or by entering in cell B18 value, euqals to P23, and another value in B20 - your formula will add value from B20 to the result). And it doesen't calculate propertly, because you have some text values in B16:M33, B35:M52
So, you can use following formula instead:
=SUMPRODUCT((B13:M13=P23)*(B15:M15)+(B32:M32=P23)*(B34:M34)+(B51:M51=P23)*(B53:M53))
Here is result of evaluating your formula (=SUMIF(B13:M13:B32:M32:B51:M51,P23, B15:M15:B34:M34:B53:M53)):

What is wrong with this Excel formula to sum() next 2 columns in the same row?

I did try to enter in a cell formula:
=SUM(ADDRESS(ROW(),COLUMN()+1):ADDRESS(ROW(),COLUMN()+2))
Intention is summing next 2 cell in the same row.
But the spreadsheet complains with error on it!
Used functions: ADDRESS(ROW(),COLUMN()+1). Work fine but together - not!
In B7 cell:
(I need to write a generic formula that is independent from location and calculates the sum of the next tho cell in the same row.
I am not interested in specific addresses or in a way to copy any specifically written formula across a spreadsheet.
I need a formula that works independently from a location!
Is it possible in Excel at all?)
Thanks.
ADDRESS returns address as a string. You cannot SUM it because SUM(A2:A3) is very different from SUM("A2:A3").
You could look into SUM(INDIRECT("A2:A3")), but you should not, for the mere reason that Excel's formulas are already relative unless made absolute.
If you want to sum two cells to the right of B7, enter =SUM(C7:D7) to B7. The formula will change if you copy it to another cell.
If you meant to enter the formula with a macro, then use the R1C1 notation and enter =SUM(RC[1]:RC[2]).
sorry im dont speak english , but a have what you need
= SUM(INDIRECT(CONCATENATE(ADDRESS(ROW();COLUMN()+1);":"; ADDRESS(ROW();COLUMN()+2))))
Regards

Resources