TEXTJOIN of INDEX MATCH unique values if value on another table is contained in a cell - indexing

On cell B5 I'm trying to get a TEXTJOIN with delimiter "," of INDEX MATCH to the price range you see on Table B. Because cell A5 contains "Apple" then "$$$" is one of the values I need, also A5 contains "Banana" then "$$" is the second value i need. Finally cell A5 contains "Pineapple" but because "$$$" is already was selected because of apple then no need to add it again.
Any help will be much appreciated.
What would I do if instead of 1 cell like A5, I will have multiple rows like this:
What would I do if I have a SKU that has only some of the Fruits and I have to use the formula based on the SKU?

With Excel 365, you can do:
=TEXTJOIN(",", 1, UNIQUE( XLOOKUP( FILTERXML( "<m><s>" & SUBSTITUTE( [#Fruits], "|", "</s><s>" ) & "</s></m>", "//s" ),
TableB[Fruit], TableB[Price Range],0)) )

Related

TEXTJOIN of INDEX MATCH unique values if value on another table is contained in a cell in the same row

On Column B I'm trying to get a TEXTJOIN with delimiter "," of INDEX MATCH to the price range you see on Table B. Because cell A5 contains "Apple" then "$$$" is one of the values I need, also A6 contains "Banana" then "$$" is the second value i need. Finally cell A7 contains "Pineapple" but because "$$$" is already was selected because of apple then no need to add it again.

Searching and comparing various values using VBA

I have to create a macro which will:
Get the value from the cell A1 search this value in column C.
If the value in cell A1 exists in column C, the macro needs to be compare the value in cell B1 with values in column D.
If the value in cell A1 exists in column C AND the value in cell B1 exists in column D, then the text "Values found" should appear in cell E1.
The above needs to happen for all non empty rows in column A.
I was trying to use the following formula:
=IF(ISERROR(MATCH(A2,$C$2:$C$138,0)),"Load number not found","Load number found")
But it not working as I want. I have limited access to internet so I can't check all web sites. Would you please help me. Thanks a lot.
To check if A1 is in column C and if B1 is in column D (in the same row A1 was found in column C), then you need to do the following:
=IF(ISERROR(MATCH(A1,$C:$C,0)),"Load number not found",IF(B1=INDEX($D:$D,MATCH(A1,$C:$C,0),1),"Load number found","Load number not found"))
The first IF checks if A1 is in column C, the second IF checks if B1 is in column D (in the same row A1 was found in column C)
It will return "Load number found" only if both conditions are true. Otherwise it will return "Load number not found".
You can write a macro to do the same thing. But the easier way is to lock the cells in column E only and protect the sheet so that users will not accidentally change any of the formulas.
Update:
Since Column C can have duplicates, need to use the following array formula:
=IF(ISERROR(MATCH(1,(A1=$C:$C)*(B1=$D:$D),0)),"Load number not found","Load number found")
When you paste this formula to E1, make sure to press CTRL + Shift + Enter instead of just pressing the Enter key.
If I understand, a conventional solution with formulae is to concatenate your C and D column data and then search that. If you insert a new columnC with:
=D2&E2
copied down to suit you could apply (but say in ColumnF rather than ColumnE) your existing formula with only slight modification:
=IF(ISERROR(MATCH(A1&B1,$C$2:$C$138,0)),"Load number not found","Load number found")
subject to quite what is in which row.

Excel: A function to replicate built-in change in relative references when copying formulas

I need a function that will do what Excel does automatically when you dreag a formula: change the referneces automatically.
For example:
In A1 I have "= A2 + A3"
If i copy this to say C3 it will have: "= C4 + C5"
I need to WRITE a formula in C3 that will produce this.
Any ideas? VBA solution is also welcome
CLARIFICATION:
In need this to be as general as possible.
Meaning A1 can contain ANY formula of any type, containing references to other cells.
for example: "= A2 + A3" or "= VLOOKUP(A2, $C$1:$E$7, 2, True)"
In need to move have this formula, whatever it is, copied to another cell (say C3), w/o the built in copy/paste, and have the references (that aren't set with $) change relatively.
I thought there might be a function to write in the destination file to do this.
I have tried writing an Eval function, and i managed to copy the formula from A1 and have it evaluated in C3, but the references would not change
This question lacks a bit of clarity, but I think this might be what you're after:
=SUM(OFFSET(C3,1,0,2))
This will sum the two cells directly below the given cell (in this case, cell C3). That is, it offsets C3 by 1 row, 0 columns, and grabs a height of 2 cells and then passes the result to the SUM function.
This VBA code would do what you are looking by setting the formula in the active cell:
ActiveCell.FormulaR1C1 = "=R[+1]C+R[+2]C"
You can use the Indirect() function using relative reference style.
For example, if you were in A1 and wanted to sum B1 & C1, it would look as follows:
A1: =INDIRECT("RC[1]",0)+INDIRECT("RC[2]",0)
That will change as you move the cell around to always sum the 2 cells to the left of the cell.
For your specific example (A1 = A2 + A3 || C3 = C4 + C5), it would be as follows:
=INDIRECT("R[1]C",0)+INDIRECT("R[2]C",0)
Hope that does the trick!!

Google spreadsheet get cell value with row and column index

How we can get value from a cell in google spreadsheet?
I have row and column index from ROW() and COLUMN() - 1.
In other words what is the other way to do "=B1" i have row as 1 and column as 2.
Any suggestion, a single spreadsheet query. other than add function to spreadsheet.
Say the row number is in A1, and the column number is in A2, any of these should work:
=OFFSET(A1;A1-1;A2-1)
=INDIRECT("R"&A1&"C"&A2)
=INDEX(A1:400000;A1;A2)
To do so use indirect() as such:
=indirect("'PAGE ASD'!"&A2&A3)
where A2 contains the letters to column like "D" or "AA"
where A3 contains the number to row like "2" or "35"
and the page you are calling the data from is called "PAGE ASD"

Clear Contents of a Column

How would I clear the contents of a column from cell A3 to cell __ where __ represents the last entry in the column (assuming there are no empty spaces between entries).
Thanks for the help.
range("A3", Range("A" & Columns("A").SpecialCells(xlCellTypeLastCell).Row)).Delete
That will delete A3 through the last cell in column A, regardless of any blanks in the column.
range("A3", range("A3").End(xlDown)).Delete
That will delete from A3 down to the first blank cell after A3 in column A.
EDIT: Fixed the first code snippet so it only deletes cells in column A.
Range("A3", Range("A3").End(xlDown)).Clear
Using .Delete will actually delete the cells, shifting up any cells that might appear after this list (separated by a blank cell). If you just want to clear the contents, .Clear is a good way to go.
I would use a vbNullString, because it's slightly faster and works efficently on huge amount of data worksheets.
Paste 'nothing' from A3 to the first blank cell in column A:
Range(Cells(1,3), Cells(Range("A3").End(xlDown).Row,1)).Value = vbNullString
Paste 'nothing' from A3 to the last cell in column A:
Range(Cells(1,3), Cells(Range("A3").SpecialCells(xlTypeLastCell),1)).Value = vbNullString
I have had good results with this:
Set tbl = ActiveSheet.ListObjects("Table_Name")
Count = tbl.DataBodyRange.Rows.Count
Range("AC2:AC" + CStr(Count)).Select
Selection.ClearContents