I have three worksheets:
Results:
|A |F |
--------------
|J123 |56 |
|J321 |53 |
|J122 |56 |
Reference B:
|A |B |E |
--------------------
|J123 |56 |J122 |
|J421 |63 |J422 |
Reference L1:
|A |B |E |
--------------------
|J423 |66 |J422 |
|J321 |53 |J322 |
Cells in column F of the Results worksheet has this code, and works most of the time:
=IFERROR((IFERROR(INDEX('L1'!$B$2:$B$1500,MATCH($C2,'L1'!$A$2:$A$1500,0)),INDEX(B!$B$2:$B$1500,MATCH($C2,B!$A$2:$A$1500,0)))),(IFERROR(INDEX('L1'!$B$2:$B$1500,MATCH($C2,'L1'!$E$2:$E$1500,0)),INDEX(B!$B$2:$B$1500,MATCH($C2,B!$E$2:$E$1500,0)))))
The intended function is to search column A in Ref. L1 for the string in column A of the results worksheet and return the value of column B that is on the same line as the string found in Ref L1 into column F of the Results worksheet if the value is found. If it is not found then search column E and so on. If it is not found there, do the same searches in Ref. B.
It seems to work about 80% of the time and when it does not, performing the column search manually does yield a result.
Any help is appreciated.
The error was with the cell data type. I found the fix when I had searched for "vlookup unexpected #N/A". It would also apply with the INDEX/MATCH technique because they are vulnerable to the same issue of a number of a text type not being equivalent to a number of a numeric type.
The Text to columns feature under the data tab can fix it just by selecting the column -> text to data -> finish. For multiple you can find VBA macros that can pull it off.
Doing it on your lookup columns and your data source columns will ensure that the function is trying to match the same data types.
Related
Thanks for reading this!
Lets say we have 2 columns in this workbook called "Data":
| Column A | Column B |
| -------- | -------------- |
| Joshua | Noah |
| Daniel | Joshua |
In another workbook, I want the user to input some random name in a cell.
Below that cell, I want to be able to show him/her, in which column that name lies. E.g. if he types "Joshua", I want to be shown below:
||
|--|
|Column A|
|Column B|
I prefer using a formula, instead of VBA, as it would mess with my not-so-experienced end-user!
Notes: See below my attempt if you find it useful:
(1) I tried that using a nested IF + FILTER functions inside, but the IF returns only the first TRUE column, like this:
| |
|------|
| Column A |
| Column A |
Here is my actual formula, where I'm referring to split ranges in sheet "6", where I have 4 columns:
IF(NOT(ISERROR(FILTER('6'!B4#,ISNUMBER(SEARCH($F$4,'6'!B4#))))),'6'!$B$1,
IF(NOT(ISERROR(FILTER('6'!D4#,ISNUMBER(SEARCH($F$4,'6'!D4#))))),'6'!$D$1,
IF(NOT(ISERROR(FILTER('6'!F4#,ISNUMBER(SEARCH($F$4,'6'!F4#))))),'6'!$F$1,
IF(NOT(ISERROR(FILTER('6'!H4#,ISNUMBER(SEARCH($F$4,'6'!H4#))))),'6'!$H$1,""))))
You could use:
Formula in D2:
=FILTER(TRANSPOSE(A1:B1),MMULT(--(TRANSPOSE(A2:B3)=D1),SEQUENCE(ROWS(A2:B3),,,0)),"")
You can get the column numbers with this formula (original data on worksheet "10")
=AGGREGATE(15,6,1/('10'!A:D="Joshua")*COLUMN('10'!A:D),SEQUENCE(COUNTIF('10'!A:D,"Joshua")))
Although I suggest reducing the range references from full columns to something shorter to reduce calculation times.
With Office 365, you can convert the column number to the letter with this:
=LET(col,AGGREGATE(15,6,1/('10'!A:D="Joshua")*COLUMN('10'!A:D),SEQUENCE(COUNTIF('10'!A:D,"Joshua"))),
adr,ADDRESS(1,col,2),
"Column " & LEFT(adr,FIND("$",adr)-1))
I have a random list of numbers and a lengthy Excel sheet. I'd like to select all rows that don't have a number from the list as the value of Column B.
For example, is this is my chart...
|A |B |
|n1|0 |
|n2|1 |
|n3|3 |
|n4|4 |
|n5|7 |
|n6|8 |
|n7|10|
|n8|11|
|n9|15|
... and my range list is {0, 3, 7, 10, 11, 15}, I'd like to delete all the rows that don't meet the criteria, resulting in this new table:
|A |B |
|n1|0 |
|n3|3 |
|n5|7 |
|n7|10|
|n8|11|
|n9|15|
I'm guessing it involved the MATCH and RANGE commands somehow, but I can't for the life of me figure out how to code in Excel...
Thanks in advance!
Create a helper column using a formula like:
=ISERROR(MATCH(B2,{0,3,7,10,11,15},0))
Then you can filter on either TRUE or FALSE as necessary depending if you want to select the rows to delete or keep respectively.
I have a range containing values such as:
169.7978
168.633
168.5479
168.7819
167.7407
165.4146
165.1232
I don't need the maximum value of the range, i.e., the first cell in this example), but the last relative maximum, which in this case is the fourth cell. Is there a way to get this value without having to write a VBA macro? The formula must be general enough to work with a multiple number of maxima.
It may be a bit limited, but you may start somewhere as below.
Stated array in the OP is:
+----------+---+
| y | x |
+----------+---+
| 169.7978 | 1 |
| 168.633 | 2 |
| 168.5479 | 3 |
| 168.7819 | 4 |
| 167.7407 | 5 |
| 165.4146 | 6 |
| 165.1232 | 7 |
+----------+---+
Given this, you can find direct adjacency relative min/max with the following helper columns
Assign a Global_Rank helper column and look for y distro identical trend on both adjacent f(x) with the following formulas ( assuming your data is sorted by the x index )( formulas from Row 2 and filled down ).
RelativeMax:
=IF(AND(D2<=D1,D2<=D3),"RelativeMax","")
RelativeMin:
=IF(AND(D2>=D1,D2>=D3),"RelativeMin","")
Modify as needed. Hope this helps.
Edit:
Although...
If you're going to assume the data is ordered properly, you could also just use =IF(AND(B2>=B1,B2>=B3),"RelativeMin",IF(AND(B2<=B1,B2<=B3),"RelativeMax","")) and skip all the malarkey. This should work with multiple maxima/minima. Please report back with results from your dataset!
"main" is a worksheet with a "Week ending" column in it.
"expenses" is a worksheet with expense figure in column B and specific dates in column A.
I want to sum the expenses that occur on or up to 7 days before the main Week ending date.
Following the examples here: https://www.ablebits.com/office-addins-blog/2014/11/04/excel-sumif-function-formula-examples/
I came up with this
=SUMIF(expenses!A2:expenses!A1024,main!$A$2&"<="&expenses!$A$2,expenses!B2:expenses!B1024)
But it gives me zero.
EDIT
The worksheets look like this:
Main
|A |B |C |D |E |F |
|Week Ending| | | | |Expenses |
|16/11/2014 | | | | |formula goes here = should total 100|
|23/11/2014 | | | | |formula goes here = should total 25|
Expenses
|A |B |
|Date |Value|
|10/11/2014 |5.00|
|11/11/2014 |20.00|
|12/11/2014 |15.00|
|12/11/2014 |10.00|
|10/11/2014 |50.00|
|17/11/2014 |5.00|
|18/11/2014 |20.00|
This works if I just put the week ending date in the expenses sheet:
=SUMIF(expenses!A2:expenses!A1024, main!a2, expenses!b2:expenses!b1024)
But I can't change the dates because they have to match the receipts. So I tried using AND:
=SUMIF(expenses!A2:A1024, AND("<="&main!A2, ">"&main!A2-7), expenses!A2:expenses!A1024)
Still zero.
#pnuts
I tried your SUMIFS suggestion but I still get zero.
You could also try:
=SUMPRODUCT((expenses!$A$1:$A$1024>=main!$A$2-7)*(expenses!$B$1:$B$1024))
Because I think you need two conditions (one for each end of each week) I suggest SUMIFS:
=SUMIFS(Expenses!A2:A1024,Expenses!B2:B1024,"<="&Main!C2,Expenses!B2:B1024,">"&Main!C2-7)
This might be simplified if the results are in Main (eg next to the Week ending values, assumed to be in ColumnC) by not specifying that sheet.
If obliged to resort to SUMIF you might add up to the week ending date with one part of the formula and deduct up to the previous weekending date with the other part.
So I have a record set comprising a lastName, firstName, Address, and PolicyID (and a bunch of other columns).
I want to see if there are more than one "Tim Jones" not just more than one Tim and/or more than one person with the last name of Jones. I do not want to create additional columns in the worksheet, nor do I want to use conditional formatting or have the user use a formula in the formula bar. The goal is for this to be hands-off for the user, save for executing a macro.
I am trying to run a loop that stores the row numbers of records where the first+last name appear elsewhere in the record-set. See table:
Legend: M = Matches, X = does not match
| First | Last | Address | PolicyID | Description |
|-------|------|---------|-----------|-------------------------------------------------|
| M | M | M | M | Duplicate Row, Delete duplicates |
| M | M | M | X | Same person, multiple Policies, mark rows yellow|
| M | M | X | M | Same person, multiple addresses, mark rows blue |
| M | M | X | X | Not necessarily the same person, mark grey |
I figured running additional checks against the smaller subset of records where the first and last name matched would help this run more efficiently.
The description column details what I am looking to do with the data initial as far as formatting. Eventually I would move/copy/delete rows depending on which criteria they met.
I believe there's an easier way you could do this without the use of VBA. Place this formula in the Description column for the 3rd line in Excel (e.g. cell E3) and then copy it down. If you still need rows to change color, you could set up conditional formatting based on the Description results.
=IF(COUNTIFS(A:A,A3,B:B,B3,C:C,C3,D:D,D3)>1,"Duplicate Row",IF(COUNTIFS(A:A,A3,B:B,B3,C:C,C3)>1,"Same person, multiple Policies",IF(COUNTIFS(A:A,A3,B:B,B3,D:D,D3)>1,"Same person, multiple addresses",IF(COUNTIFS(A:A,A3,B:B,B3)>1,"Not necessarily the same person",""))))