Formula with variable references depending on cell value

formulafinder

New Member
Joined
Sep 3, 2019
Messages
1
Hello! I have an issue writing a formula that I hope has an easy response.

I have a dataset with people who have multiple rows of data relating to them. If a certain number of rows meet criteria (eg, are within a certain time period of each other), I would like Value Y on that row to be blank. I've figured out the criteria with one hang-up: one of the criteria includes a number that can change -- the maximum count of rows meeting criteria. Once that number of rows has been hit, the row should not be blank. Here's an example:

Maximum count of rows meeting criteria3

<tbody>
</tbody>


PersonValue XValue Y
A1010
A20
A30
A4040

<tbody>
</tbody>


Right now, my formula relies on directly referencing the cells above it =IF(AND(A1="",A2="") where if that max number increases, you'd have to add A3 and so on. Is there a way to have my formula reference the max count of rows cells and dynamically update, so if the max count was 4, A3 would be added to the formula, with a result like this:

Maximum count of rows meeting criteria4

<tbody>
</tbody>


PersonValue XValue Y
A1010
A20
A30
A40


<tbody>
</tbody>


I tried playing around with Indirect and wasn't able to make it work. I appreciate any thoughts/ideas/approaches. Also, apologies if there was a similar thread -- I tried searching around and couldn't find anything similar, but I'm likely just missing the best keywords.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
COLUMN
/ ROW
ABCDEF
1PersonValue_XValue_YMAX_row_count
2A10=IF((COUNTIFS($A$1:$A2;$A2))/$F$2-(1/$F$2)=INT((COUNTIFS($A$1:$A2;$A2))/$F$2-(1/$F$2))=TRUE;B2;"")4
3A20
4A30
5A40

<tbody>
</tbody>



To break down the formula:

=IF((COUNTIFS($A$1:$A2;$A2))/$F$2-(1/$F$2)=INT((COUNTIFS($A$1:$A2;$A2))/$F$2-(1/$F$2))=TRUE;B2;"")
Count how often en employee is listed.

=IF((COUNTIFS($A$1:$A2;$A2))/$F$2-(1/$F$2)=INT((COUNTIFS($A$1:$A2;$A2))/$F$2-(1/$F$2))=TRUE;B2;"")
Divides how often the employee is listed with the max row count as listed in cell F2.

=IF((COUNTIFS($A$1:$A2;$A2))/$F$2-(1/$F$2)=INT((COUNTIFS($A$1:$A2;$A2))/$F$2-(1/$F$2))=TRUE;B2;"")
I am skipping the blue bit, but will get back to that later.
This step determines if the amount of employees divided by the max row count is a full number (integer).

=IF((COUNTIFS($A$1:$A2;$A2))/$F$2-(1/$F$2)=INT((COUNTIFS($A$1:$A2;$A2))/$F$2-(1/$F$2))=TRUE;B2;"")
You will want to display value Y for all rows where the calculation returns a full number.
If the number is a multiple of max row count, then you can display Value Y.

=IF((COUNTIFS($A$1:$A2;$A2))/$F$2-(1/$F$2)=INT((COUNTIFS($A$1:$A2;$A2))/$F$2-(1/$F$2))=TRUE;B2;"")
To get back to the bit that was skipped earlier.
To make sure the formula displays the first entry, you have to add this bit to the calculation. Without it, every 4th entry would be displayed instead of every 1st entry (assuming value in F2 is 4).
 
Upvote 0

Forum statistics

Threads
1,214,929
Messages
6,122,314
Members
449,081
Latest member
tanurai

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