Excel 2010 find/lookup based on table Data - excel

I have a Excel (Office2010) range table as per following
using excel formulas (no VBA) how do i find
What subjects "Jane" has completed?
Who has done "Spanish"
i have tried few types of vlookup,hlookup index/match without having any luck
any help would be much appreciated.
Due to Office 2010 i cannot use TEXTJOIN function (as answered by #Louis Ries)
Thanks in Advance.

I was able to find a solution in Excel 2016, but after extensive research, I've found no way to select the data and eliminate values that don't match with formulas, and no VBA or add-ins. I'm quite interested in learning a solution for this that is compatible with previous versions of excel, but don't believe I'll find one anytime soon. My best suggestion is to obsolesce your version of Excel for 2016.
If you are using Excel 2016:
Note: I created a copy of the data and inserted it as a Table("Table1") with headers.
Enter this into a cell as an array formula(CTRL + SHIFT + ENTER).
It will retrieve all subjects that Jane has completed.
=TEXTJOIN("; ",1,REPT(Table1[Subject],1*(Table1[Jane]="x")))
Enter this into a cell as an array formula (CTRL + SHIFT + ENTER).
It will retrieve all headers where the row you desire has an x.
=TEXTJOIN("; ",1,REPT(Table1[#Headers],1*(A4:F4="x")))
If you select a row and create an alias(i.e. select A4:F4 and in name manger, alias it as Spanish), you can use this. (CTRL+SHIFT+ENTER)
=TEXTJOIN("; ",1,REPT(Table1[#Headers],1*(Spanish="x")))

Related

Dynamic sort top/bottom N values in excel 2019

I'm currently using excel 365 but need to make a spreadsheet compatible with 2019. I have a list of unique departments each with a specific volume of production. I need to create a dynamic filter for the bottom 5 producers, along with a vlookup alternative to get the values so I can graph them.
In excel 365 it's as simple as
Departments: =FILTER(Metrics!$B$2:$B$41,Metrics!$AL$2:$AL$41<E22)
Values: =IFERROR(VLOOKUP(D25#,Metrics!$B$2:$AM$41,37,FALSE),"")
The table goes from A1:A41 with row 1 being the headers.
I've tried using MIN and SMALL but can't figure out how to get more than one value. I'm open to but would prefer not to use VBA if I can help it.
For a function using SMALL, you'll have to use it in an array.
To do that, type out your formula, then instead of hitting enter like usual, press 'ctrl + shift + enter' to tell Excel to use an array. This will put {} around your formula to indicate it worked properly. From there just drag your formula down your desired amount of columns and should be good to go.

AGGREGATE formula not automatically calculating when written to results spreadsheet

I have a python 3.7 script that has been developed using the OPENPYXL (v2.5.10) library to take data from a number of excel workbooks, to process that data and then to write to a separate excel workbook. The results workbook contains around 100 named ranges and numerous formula which all work as expected including automatically calculating when the workbook is opened in excel.
I am having trouble with one particular formula group which includes the AGGREGATE function. In this case the formula writes to the results workbook, to the correct cell and in the correct form. While other formulas show the resulting value on opening the workbook, this sequence of formulas only show a result if you select the cell, place the cursor in the formula bar (as if you are editing the formula) and then you push the enter/return key. No change or edit is made to the formula. Once you have done this the formula works as expected.
I have tested this on both the latest macOS and windows versions of excel and I get the same behaviour. I should add that trying the 'calculate now', CtrlShiftAltF9, and 'calculate sheet' options do not have any impact. The only time the formula calculates is if you use the enter/return key.
The code that writes the formula is:
activeSheet.cell(row, col).value = f"=IFERROR(INDEX({rngData}, AGGREGATE(15,3,({rng}={cellRef})/({rng}={cellRef})*ROW({rng}),{nth}),{colIndex}),\"\")"
which gives, for example, a correct result in the excel workbook cell as:
=IFERROR(INDEX(_monthAgedDebt_Data, AGGREGATE(15,3,(_monthAgedDebt_ProjectNumbers=$L$4)/(_monthAgedDebt_ProjectNumbers=$L$4)*ROW(_monthAgedDebt_ProjectNumbers),1),6),"")
So in summary:
the code works as it writes the correct formula to the correct cell and in the correct form
in excel the formula does not automatically calculate but only works if you edit the formula in the cell, make no changes, and push enter/return to exit the edit
Is it an issue with AGGREGATE producing an array result? I chose this form of formula principally because you do not need a CTL-SHIFT-ENTER to make it work. If you enter it directly into a cell in excel you can enter it as a normal formula.
I haven't been able to find help on stack overflow other than this one. However, the solution proposed here doesn't work either.
This question poses a similar issue but has no relevant responses.
This question may hold a clue but I don't seem to be able to make that work as well.
Any thoughts on how to fix this issue appreciated. I am not sure if it is an openpyxl issue or an excel issue and am not sure what else to test.
All - the final answer for completeness.
It turns out that the key to solving this issue lay with OPENPYXL and that the guidance provided in the answer by Charlie Clark to this
question
was correct. I had initially applied the solution incorrectly.
I changed the formula to:
activeSheet.cell(row, col).value = \
f"=IFERROR(INDEX({rngData}, _xlfn.AGGREGATE(15,3,({rng}={cellRef})/({rng}={cellRef})*ROW({rng}),{nth}),{colIndex}),\"\")"
by adding in the '_xlfn.' to the front of the AGGREGATE function statement.
The excel spreadsheet now works as expected without the need to edit the cell containing the formula.

MS Excel 2010 MAXIFS equivalent in VBA Userform

I've created an Excel Userform to facilitate the data entry of new lines into a contract register. I have a field that auto-generates a new unique contract number by looking for the largest number in the list of contract numbers (Column A) and then adds 1. This formula works perfectly:
Me.tbContractNumber = Application.WorksheetFunction.Max(Sheet1.UsedRange.Columns(1)) + 1
I now have to add an IF criteria to filter out any contract numbers LESS Than "2018000". I have worked out how to do this in a normal Excel workbook using MAXIFS but apparently MAXIFS is not an available function in VBA?
Can someone suggest an equivalent VBA code to the below Excel formula? Thanking you in advance!
=MAXIFS(A2:A500,A2:A500,"<2018000")+1
EDIT Our work computers run 2010 and won't allow me to add the MS Office 16.0 Object Library so MAXIFS function will not work. I can get the following array formula to work but I have never used an array formula in VBA. Could someone please suggest an equivalent VBA code to the below Excel formula? Thanking you in advance!
{=MAX(IF(A:A<2018000,A:A)) +1}
If you're looking for the largest number anyway, do you need to filter out anything lower than 2018000? If you have at least one entry equal to/higher than 2018000, your end result will be higher regardless of the other entries.
I'm sure there are more efficient ways of doing it, but if you are happy with:
Me.tbContractNumber = Application.WorksheetFunction.Max(Sheet1.UsedRange.Columns(1)) + 1
then try:
me.tbContractNumber = Application.WorksheetFunction.MaxIfs(Sheet1.UsedRange.Columns(1), Sheet1.UsedRange.Columns(1), ">" & 2018000) + 1
...but apparently MAXIFS is not an available function in VBA. In VBA it is not present, but if you add the Excel 16.0 Object Library (second on the screenshot) to your project, you would be able to access it as follows:
Application.WorksheetFunction.MaxIfs 'Only in Excel
Excel.WorksheetFunction.MaxIfs 'Any host of VBA - Excel, Access, Word
The library is added by default, if you work in Excel. Concerning "translation" the working formula from Excel to VBA, check this:
https://stackoverflow.com/a/49363501/5448626
I just learned the Evaluate function! So equivalent of the array formula I want to use converts in VBA to:
Me.tbContractNumber = Evaluate("=MAX(IF(" & "A:A" & "<2018000," & "A:A" & "))+1")

Dynamically extract a list of unique values from a column range in Excel?

I found this example in an excel tutorial
The following image is my desired result. and the following formula is supposed to be able to extract the unique records dynamically. I know how to do this with VBA but i really want to make this a formula without using a macro.
=IFERROR(INDEX($B$2:$B$9, MATCH(0,COUNTIF($D$1:D1, $B$2:$B$9), 0)),"")
I have tried the above formula as given in the example link above but it returns with error. I am assuming that this worked at some point in excel however it no longer works with Excel 2016. Can someone clarify why this formula no longer works? Thank you.
Answering my own question about 5 minutes later, so i read the patch nodes on the how match changed from excel 2008 to 2016. You need to use the index rather than the count.
=IFERROR(INDEX($B$2:$B$9, MATCH(0,INDEX(COUNTIF($D$1:D1,$B$2:$B$9),0,0),0)),"0)),"")")
Recommended edit to the formula to change the value returned on error to a blank:
=IFERROR(INDEX($B$2:$B$9, MATCH(0,INDEX(COUNTIF($D$1:D1,$B$2:$B$9),0,0),0)),"")

Sum Filtered Values Excel

I am finding the sum of filtered values while ignoring #DIV/0! errors. As such, I combined the following formulas:
=SUBTOTAL(9,$I$2:$I$349)
and
=SUMIF($I$2:$I$349,"<>#DIV/0!")
To get:
SUBTOTAL(9,SUMIF($I$2:$I$349,"<>#DIV/0!"))
However, excel returns an error. Any insights?
Is it that I cannot place a formula within another formula?
Which version of Excel are you using?
In Excel 2010 and later versions AGGREGATE function works a little bit like SUBTOTAL - it can perform various functions while ignoring hidden rows.......but it also has options to ignore error values, so without any helper columns you can use this single formula
=AGGREGATE(9,7,I2:I349)
9 denotes "sum" as per SUBTOTAL while 7 as the 2nd argument indicates that error values and hidden values should be ignored. There are other options, see Excel Help for more
I found this bit of brilliance with some digging on the webs: http://www.excelbanter.com/showthread.php?p=760730
It's a difficult formula to follow, but should do the trick.
{=SUM(IF(ISNUMBER($I$2:$I$349),$I$2:$I$349)*(SUBTOTAL(3,OFFSET($I$2:$I$349,ROW($I$2:$I$349)-MIN(ROW($I$2:$I$349)),0,1))))}
It's an array formula, so make sure to press Ctrl + Shift + Enter (instead of just Enter).
I can't pretend to understand it all without really digging into it, but it works!
Use a helper column
In H2 enter:
=IFERROR(G2,"")
and copy down and then use:
=SUBTOTAL(9,$H$2:$H$349)
=IFERROR(SUBTOTAL(9,$I$2:$I$349),"")

Resources