compare values with values in a table - excel

what i want is for cell C10 to contain the value of column 5 in my table, only if column 1 and 2 both match the date and name in cells a1 and b1
ive tried to achieve this with a formula but i can only get it to compare 2 things, formula below.
i can get it to match the date in the sheet with the date in the table, then give me column 5's value for that matching row, but i cant get it to acknowledge the name as well so cell C10 is getting a note for someone else because the dates match despite the names not matching.
i have also included a mockup up with 4 examples of what should be happening.
I think it is possible it can be done by formula, i found something when i was trying to google this problem but i dont have a clue what its talking about and i feel like it would be really easy with vba
https://exceljet.net/formula/index-and-match-with-multiple-criteria
=INDEX(TblNotes[#All],MATCH(Date,TblNotes[[#All],[Date]],0),5)

you may want to use Database formulas
insert a row above the first one
write "Date" and "Name" in cells A1 and B1 respectively
place the following formula in C10
=DGET(TblNotes[#All],"Comment",A1:B2)

Related

Excel table auto-fills incorrect formula when inserting rows

I have an Excel 2019 Workbook in which I have a sheet with a range of cells defined as a table. Table columns are A to H, where columns A and C contains formulas and the others have to be manually compiled with information by users. The sheet is protected, with the cells in columns without formulas unlocked, so that users cannot alter formulas, but they are allowed to add rows (in the middle of the table, not at its end) as this can be required.
The problem is that when adding rows, the formula auto-filled in column A for the row below the new one is incorrect.
Detailed explanation
Column A is used to assign an unique number to what si written in column B, so that if an element in column B is repeated, the corresponding number in column A is repeated as well
The first cell of the table in column A (A4) contains the value "1"
Cell A5 contains the formula "=IF(B5=B4;A4;A4+1)"
Cell A6 contains the formula "=IF(B6=B5;A5;A5+1)", and so on
If I add a row between 5 and 6, the formula in the new cell A6 is correct, but the formula in cell A7 becomes "=IF(B7=B5;A5;A5+1)", instead of the correct "=IF(B7=B6;A6;A6+1)"
Formulas in all the cells below A7 are correct
If I manually fill the formula in A7 form another cell by using the fill handle, the formula corrects itself
I know there is a similar thread MS Excel Auto-Fills Incorrect Formula When Adding Rows and I already tried some workarounds described there such as clear the column and then add the formula back again, but without results.
My situation seems to be different because the formula is not present in the entire column because of the "1" in A4.
Even though the problem can be manually addressed with little effort via the fill handle, this is not a suitable solution since users may not correct the formula, which is needed for some other calculations in another sheet of the Workbook.
The behaviour you describe is normal and nothing to do with tables. If you insert a row in between a cell and another cell it references directly in a formula, that formula will not adjust to refer to the new cell. In other words if A6 contains =A5 and you insert a row between rows 5 and 6, that =A5 will not suddenly alter to be =A6.
If you need that behaviour, you would need to use something like INDEX or INDIRECT - for example:
=INDEX(A:A,ROW()-1)
will always refer to the cell in the row above the formula cell.

Finding partial matches within an if statement

Does anyone know how I can write an if statement that searches for partials in VBA? For example, if A2 and A3 both contain Jon, I would like the totals under the 2020 column to be summed, and then it would move down and check the values in A4 and A5. It should work the same way for Mary. But with ben, it should only total A6 because the cell underneath contains Chip. Then it should go down again and check the following two cells for a match. This is for a report that changes weekly, so the names will not always be the same. Any help is appreciated. Thank you.
As Rno said, name uniques would become an issue, but for this small data set you can add another column of name values in column F and do a sumif formula on those separated names.
See Formulas Used Pic
In cell f2 =TRIM(RIGHT(A2,LEN(A2)-FIND("-",A2,1)))
In cell H2 =SUMIF($F:$F,$G2,B:B)

Filtering a column in a formula and correcting formula

Two part question.
I have a formula in excel that currently doesn't work, and so I want to correct this formula and then apply it to a subset of rows that I want to be able to select within a formula.
Here is a screenshot of what I am working with:
Part 1:
So the result is being calculated in cell G3. I would have expected the value to return the value 5 and not 6 as what I expect the calculation to do is the following:
1) Look in column C and find which rows are less than the threshold value in cell G3.
2) Of those rows that meet that criteria, return the values that are in column B.
3) Take the max value of those returned values which is 5.
Am I missing something here?
Part 2:
Second part of the question is that I would like to be able to apply the "correct" formula in Part 1 to a subset of rows based on the the ID's in columns A. Basically I would like to take the unique ID in cell E3 and then apply my corrected formula to all of the rows where the values in column A matches E3. This one I cannot seem to find a formula for to do.
This excel doc is going to become a general tool and so I don't want to have to select rows manually and so would like to be able to do all of the matching without selecting thins manually.
Since you have a recent version of Excel, you can use MAXIFS:
=MAXIFS(B3:B10,A3:A10,E3,C3:C10,"<=" & F3)
FYI, based on your description, 6 is the correct return value.

Is there a formula that will paste the result of a separate formula as a value?

Ex.
column A is a formula that outputs an 8 digit ID from a prior delimited calculation. I want to vlookup that ID to a separate set of data, but it is not finding the ID when the lookup value is part of a formula.
Is there a way to paste the formula result as a value in column b?
I have a list of 3000+ IDs, so using the F2, F9 trick won't work, since I would have to do that cell by cell.
Would prefer not to use VBA, but if that is the only way, can someone help simplify that process (new to using VBA)
If you have data in column A based on a left function of a bunch of numbers, and just want that result in column B, all you have to do is put:
=Value(ColRow)
in Column B. Then you can look up the value in Column B via VLookUp.
I am an avid Excel user and personally tested this solution. Though it appears #Scott beat me to it in the comment section.

Formula to Search for Data in One Column, then Apply Formula

I am working on a personal budget sheet in excel, and it's formatted based on my pay dates, to provide more drilled-down information. I have attached an example of it below for reference.
I would like to put a formula into J2, J3, and J4 which will take the data in cells C9:C26 and H9:H16, match it to the date in cells D2:D4, then subtract the expenses in D9:D26 and I9:I16 from E2, E3, and E4.
As you can see, I have just individually summed the cells; however, I would like a formula to be able to adjust as I change the value in cells C9:C26 and H9:H16.
I have found that I can do it with ONE cell, but not multiple or a range. This is the formula I used, and I cannot find a way to make it apply to the entire range of cells: =IF(C14=D3,E3-D14)
I've also tried: =IF(C9:C25=D3,E3-D9:D25) -- I know this formula doesn't work and why. I cannot figure out how to get column C to correspond with column D.
The Budget Sheet
You just need to use SumIf().
In cell J2, put this formula: =SumIf($C$9:$C$25,$I2,$D$9:$D$25)+SumIf($H$9:$H$25,$I2,$I$9:$I$25) and drag down the three cells.
With that, you can add E2-[formula] to subtract all that from E2. Or of course, just do e2-J2 instead. I think that should do what you're looking for. If it's not quite it, let me know and I can tweak.
If you plan to have more than 1 criteria go with SUMIFS
Yes, with S

Resources