Need help with formula

Russk68

Well-known Member
Joined
May 1, 2006
Messages
589
Office Version
  1. 365
Platform
  1. MacOS
Hi all,

I have 2 columns (A&B) by 8 rows. Values entered in column A can only contain a number between 1 & 8. Column B will show a 0 or 1 depending on a cell value based on column A. An empty cell or value of 1 in column A, will always show a value of 0 in the same row (ColB). A value of 2 in a cell in column A will show a 1 in the same row (ColB) and also the one below it. A value of 3 will show a 1 in the same row and also the next 2 rows and so on.
So, a value greater than 1 in column A will result a 1 in the same row (ColB) and as many rows down as the value entered in column A.

Basically, the 1 in column B is reserving rows based on the value entered in column A.

Consider yourself a genius if you even understand what I am saying.

Example:

.....A....B
1...1....0
2...2....1
3.........1
4.........0
5...3....1
6.........1
7.........1
8.........0

Thank you!

Russ
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Hi,

See how this works for you, need an Empty or Header row on top of your data, formula copied down:


Book1
AB
1
210
321
41
50
631
71
81
90
Sheet594
Cell Formulas
RangeFormula
B2=IF(LOOKUP(9,A$2:A2)=1,0,IF(COUNTIF(B$1:B1,1)A$2:A2)-SUMIF(A$2:A2,1),1,0))
 
Upvote 0
Hi genius!
This works exactly as I explained. however, I discovered a bug in my example.

I can enter a number in every row. For example, if I enter 2 in the first 2 rows, it will result with a 1 in B1:B4. In this example, I would need B1:B3 with a 1.

Basically, the number in the lower row would take priority.

Desired result
....A...B
1.........
2...2...1
3...2...1
4........1
5........0
6........0
7........0
8........0
9........0

Would you be able to tweak you formula to get this result?

Thank you!
 
Upvote 0
Updated formula per your requirements, No longer needs a Blank or Header row:


Book1
AB
10
221
321
41
50
60
70
80
Sheet594
Cell Formulas
RangeFormula
B1=IF(IFNA(LOOKUP(9,A$1:A1)=1,1),0,IF(ROW()-LOOKUP(9,A$1:A1,ROW(A$1:A1))9,A$1:A1),1,0))


Formula copied down.
 
Upvote 0

Forum statistics

Threads
1,214,784
Messages
6,121,540
Members
449,038
Latest member
Guest1337

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