Nested IF

phil133

Active Member
Joined
May 5, 2015
Messages
257
Office Version
  1. 365
Platform
  1. Windows
Hi. I have a column A with 1s, 2s and 4s. It's easier to see the example I have below. If there is a 1 it needs to see if there is another 1 right above. If it doesn't it should copy it. When it sees a 4 and all above are 1 it has to continue with the same number but the range restarts. So when it sees a 1 it should copy the new corresponding number. When there is a 2 and above there is a 1 or 4 it should copy the previous number again for the last time. If there is a 2 again it should bring 0 now. Hopefully you will understand with the example because I did not explain it well! Thanks for any help.
sample new1.xlsx
ABC
1Desired
212121
312521
412621
512021
612221
712421
812521
912421
1042221
1112727
1212827
1322127
142270
152190
162180
1712424
1812824
1922924
202310
Sheet1
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Put this formula in cell C2 and copy down for all rows:
Excel Formula:
=IF(AND(A2=2,A1=2),0,IF(OR(A1=4,AND(A2=1,A1=2),ROW()=2),B2,C1))
It seems to return the results you show.
 
Upvote 0
Solution

Forum statistics

Threads
1,214,788
Messages
6,121,597
Members
449,038
Latest member
Arbind kumar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top