How to maintain true Blank Cells when copying a column - arrays

Problem: I have data in Column A as headings of some sort and in column B I have subheadings.Because of this column A has blank cells between the headings.
If I set Cell A1 in a second sheet to be equal to A1 on the first sheet and copy this throughout the blank cells return as '0'. This messes with formulas that rely on true blank cells.
I've attached and image to visually explain the problem.
To replicate the desired output and the problem:
Enter random data into columns A and B leaving blanks in column B.
In column C enter: =SUBSTITUTE(FILTERXML("<t><s>"&TEXTJOIN("</s><s>'",,A1:B50)&"</s></t>","//s"),"'","")'
This Will return a correct result combining the heading and subheadings in a logical order.
.
However if you set say column E and F to equal Columns A and B respectively and enter the following in column G: =SUBSTITUTE(FILTERXML("<t><s>"&TEXTJOIN("</s><s>'",,D1:E50)&"</s></t>","//s"),"'","")
The data will return correctly sorted but now with a bunch of 0s between each heading and subheading because the formula now includes cells that were originally blank as 0.
What I've Tried: Aesthetically you can set '0' Cells to not display 0 in advanced setting but as the name descries its still a 0 and just hidden but not from the formula. I have tried setting the cell to Text only to try and eliminate 0 but this has no affect as numbers are still recognised as text. I have also tried to eliminate 0 with the code =IF(E1="0","",E1) and =IF(E1="0",NA(), E1). This removes the 0 or adds N/A# but ultimately these cells are still recognised as such by the above formula and a 0 is entered or the formula fails.
Does anyone know how to make one column with blank cells equal to another and still maintain True Blank Cells and not 0s? Alternatively if anyone knows how I can modify my formula to ignore 0s that would be great too. I don't have any experience in VBA but I'm willing to learn/copy and paste a code that will remove this problem.
Any help is appreciated, or if you think its not possible let me know.

Please try this formula in your cell E2 and copy down.
=LOOKUP(2,1/($A$1:$A2<>""),$A:$A)
The opposite effect is achieved with this formula.
=IF(A2="","",A2)
The first formula will copy the header to each row even where the source is blank whereas the second produces a blank cell for a blank cell. Another ay is to allow the zeros to be written but suppress their display with a cell format or a universal setting (for the whole sheet) that suppresses display of zero values.

Did you mean you would like to use a condition in TEXTJOIN(), a nested IF():
Formula in D1:
=SUBSTITUTE(FILTERXML("<t><s>'"&TEXTJOIN("</s><s>'",,IF(A2:B13<>0,A2:B13,""))&"</s></t>","//s"),"'","")

Related

Cant Get formula to enter blank cells at end of column

I have data composed on chemicals and hyphened cells in column F of sheet1.
Using the formula in sheet2: =IF('Formulation card'!F7:F60="-","",'Formulation card'!F7:F60)
This works well to convert the hyphened cells to a blank cell if present in F7:F60 of the formula card.
At at end however I get a bunch of '0's entered where Blank non hyphenated cells are present.
I've tried to use an OR Statement as follows:
=IF(OR('Formulation card'!F7:F60="-",""),"",'Formulation card'!F7:F60)
Which to me reads if a - or a "" is present return "".
However doing this just returns all columns as Blank. I though I had got my head around using OR statements but apparently not.
If someone could point out whats wrong here that would be great. Let me know if you require more information.
Internally all given indices inside an OR() statement will be processed, however only one value of FALSE or TRUE will be returned depending if any of the calculations returned TRUE. Hence why your column will stay "empty". It's actually not empty, but full of zero-width strings.
You can circumvent that behaviour in Microsoft365 using some boolean structure:
=IF(('Formulation card'!F7:F60<>"-")*('Formulation card'!F7:F60<>""),'Formulation card'!F7:F60,"")

Use of Array/VLOOKUP to create sums from lists

I'm using Excel 2007+, My plan is to create 3 connected columns, the first column is a basic description(text), to help you understand what i'm trying to do column 1 will be colours(so in the column "Red" would be a correct value to enter and this is simply typed in). Column 2 would be a modifier in the form of a list separated by commas in this example shapes and this is entered using a combination of Vlookup and VBA to call from a list in column A in the next sheet(so in this column "Triangle,Square,Circle").
Finally my problem is i want column 3 to be a sum of column 2 this would not be the sum of the shapes however, it would be the sum of values assigned to the shapes(this value would be right next to the shape in VLOOKUP list, B Column)
Hope my explanation helps, let me know if you need more info.
I have added an image for an example, where the left columns are lists to be looked up and the right is an example of what it would look like when correct.
Tried VLOOKUP but I'm missing something.
none yet
See image for expected results, the value column should auto-complete when the shape and colour columns have been filled.
https://i.stack.imgur.com/TjYTG.png

Excel find results not in one array from another

Without using VBA, is there any way to find and output the results missing from one array compared to another into cells.
I have two sheets, on Sheet1 is a list of numbers in column B and "N/A" In column J if we are done with them. On Sheet2 is we paste a list of numbers in column B. I need to be able to find the numbers missing from Sheet2 that do not have an "N/A" tag in Sheet1 and output them to column C.
I tried {=INDEX(Sheet1!B:B,MATCH(1,(Sheet1!B:B<>B:B)*(Sheet1!J:J<>"N/A"),0))} but (Sheet1!B:B<>B:B) doesn't seem to be doing what i think it should. I understand that the above formula won't give more than 1 result yet. I would need to add something to eliminate the results already in column C, but one step at a time.
Sheet1!B:B<>B:B compares corresponding cells in two sheets. Unless the numbers appear at the same exact rows in both sheets, your code will not work.
I don't think it is possible to deal with this with array formula, because Match doesn't accept an array as its first argument. But you can enter this in C1 and copy and paste to the whole column:
=IF(ISERROR(MATCH(Sheet1!B1,Sheet2!B:B,0)),IF(Sheet1!J1<>"N/A",Sheet1!B1,""),"")
There will be empty cells though.

Excel - my formula needs to incorporate the last filled cell in column

I am building a calculator that detects streamflows that falls below a certain flow rate. I have an array formula that takes a column of data, and identifies how many data points in a row fall below a particular threshold (threshold value in C12):
{=MAX(FREQUENCY(IF(E23:E12275<C12,ROW(E23:E12275)),IF(1-(E23:E12275<C12),ROW(E23:E12275))))}
This formula works, but I want to be able to build in the ability to detect the last row with entered data. In this example, the data set finishes at E12275, but datasets can extend many more rows. If I extend the formula to this:
{=MAX(FREQUENCY(IF(E23:E1000000<C12,ROW(E23:E1000000)),IF(1-(E23:E1000000<C12),ROW(E23:E1000000))))}
the formula interprets the blank cells (after the last full cell) as zero, and says that they fall below the threshold. This gives me a result of 987725 (1000000-12275)
I have built another formula that detects the bottom row cell address:
=ADDRESS(LOOKUP(2,1/(E23:E1000000<>""),ROW(E23:E1000000)),5,1)
However I am having trouble incorporating this result into the existing formula. Does anyone have any thoughts on how to do this?
NB: I have also toyed with the idea of building a formula that excludes blank cells, however the actual datasets include blank cells, which should be interpreted as "below threshold"

How to arrange table data differently by using if, match, and index?

As shown in the attached image, I need to convert A2:D10 to the format of A12:E17. The 4 tables from F1 to AB12 are my experiments using if, match, and index. Same formula gets different results and it seems to be dependent on the row position of the tables. In My previous question, I was trying to pinpoint the problem to the if function.
What am I doing wrong here?
Thanks,
Lu
enter image description here
Again, as I said in your last question: The formula has not been array entered. Array formulas need to be confirmed with Ctrl-Shift-Enter.
Without that, the first array in the IF statement does not get resolved and the Match does not return the correct result.
Make use of the Evaluate Formula tool and step through the formula.
The merged cells don't help with the cell referencing. Unmerge the cells and fill in all the labels in row 1, then use this slightly amended formula and confirm it with Ctrl-Shift-Enter. Then copy across and down.
I hope that I get the English names of the functions right:
In D14 and following cells:
=INDEX($C$1:$C$5;MATCH(1;MMULT(($B$3:$B$10=$A14)*($A$3:$A$10=B$13);1);0))
The MATCH function tells which value (by number counted from the top) matches both conditions. The INDEX function returns this value from C1:C5.

Resources