mardi 6 octobre 2020

Using nested IF function in excel: is there a way to check next row for same IF function?

Let's say I have a simplified table of only 2 columns. Column one is Group number, with groups of different sizes. Column 2 is also numbered but has a lot of blanks. I basically want to fill these blanks with the next NOT blank, if it is still in the same first-column-group.

I don't know if it works to show a table here, but this is what it is now and what I want to achieve with a simplified dataset:

What my data looks like now

How I want it to look

What I tried is to use an If function. First, it checks if B1 is blank. If it is blank, I want it to check if A1 is the same "group" value as A2. If that is also true, then I want the formula to return me the value of B2. However, if B2 is also blank I want it to loop: Check if A1/A2 are the same as A3, and then give the value of B3. And continue. Plus! If B1 is not blank to begin with it just needs to return the value B1. And if B1 is blank but A1 is not the same group as A2, I want it to remain blank (or 0 is also fine).

The only way I did this was making an extremely nested if function that kept repeating for the [if true] part, which looks like this:

=IF(B2="";(IF(A2=A3;

(IF(B3="";(IF(A3=A4;

(IF(B4="";(IF(A4=A5;

(IF(B5="";(IF(A5=A6;

(IF(B6="";(IF(A6=A7;

(IF(B7="";(IF(A7=A8;

(IF(B8="";(IF(A8=A9;"xx";""))

;B8));""));B7));""));B6));""));B5));""));B4));""));B3));""));B2)

However, sometimes there are 100+ blanks within one group, and I'm trying to avoid looping 100+ repetitions of that formula.Right now, when there are not enough loops for within a group, it shows the xx. Is there no way to just replace the B1 by a continuous string of cells of column B? I looked at the Row function but it only works when you pull it down if I understand it correctly.

Would really appreciate the help!

Aucun commentaire:

Enregistrer un commentaire