calculating stock market bonus shares

mwvirk

Board Regular
Joined
Mar 2, 2011
Messages
247
Office Version
  1. 2016
Platform
  1. Windows
hello

I am calculating how many bonus shares (Flag marked as B) I have received from the stock market for each of my stocks
and then also checking if I sell some bonus shares then how many are still in my portfolio

in this excel file, I have 2 sheets
sheet1 is for buying, selling and bonus shares received
sheet2 is to check the status that how many bonus shares were received and how many are left. if all are sold then I should get 0 in sheet2 cell D
(but in all cases, I want to keep the actual bonus shares received in sheet2 cell C)

I have multiple issues here in this sheet2:

1- if the cell H in sheet1 is blank then cell D in sheet2 is not counting the total (i should have a value of 0 at least in sheet1 cell H to get the result since the blank cell is not showing the count in sheet2 cell D)
2- if I partially or fully sell bonus shares in sheet1 then it's showing balance zero in all cases in sheet2 cell D (i am checking here to know how many are still in my portfolio)

kindly check and help.

thanks


Test-Copy.xlsx
ABCDEFGH
1Stock nameFlagReceivedSold
2AppleR1000
3GoogleR1500
4IntelR2000
5FacebookR2500
6AppleB105
7GoogleB150
8IntelB200
9FacebookB250
10AppleR2000
11GoogleR2500
12IntelR3000
13FacebookR3500
14AppleB15
15GoogleB20
16IntelB25
17FacebookB30
Sheet1





Test-Copy.xlsx
ABCD
1Apple250
2Google3515
3Intel4520
4Facebook5525
Sheet2
Cell Formulas
RangeFormula
C1:C4C1=SUMIFS(Sheet1!F:F,Sheet1!A:A,A1,Sheet1!C:C,"B")
D1:D4D1=SUMIFS(Sheet1!F:F,Sheet1!A:A,A1,Sheet1!C:C,"B",Sheet1!H:H,0)
 
Thank you for the explanation. So you have multiple two-letter codes: NA, PP, PS, PB, KP...is that correct?
Within each common two-letter code (say "NA"), you have a common set of candidates for each NA#, correct?
But are the sets of candidates different between any two two-letter codes. For example if Candidates named "a", "b", and "c" appear in all of the NA# groups, you would not find the same candidates "a", "b", and "c" in the PP# groups, correct? Are the candidates different between NA and PP and PS and...

In your post #19 above, you have begun to duplicate the list of candidates in W:X. That is not what the worksheet was designed for. W:X should have only a unique list of candidates for one set of two-letter codes that appear in column A. So if you wanted to see a vote tabulation table created for 80 NA#'s, you would have NA-001 through NA-280 going down column A, one entry for each row. And if you had 30 candidates, each of whom should appear for every NA#, the W:X would have only 30 candidates listed. The formulas in J:M, when pulled down the page, will automatically create the combination table consisting of NA# and candidate/party name.

You could duplicate this worksheet, one for every two-letter code: NA on one sheet, PP on another sheet, etc.

Regarding the determination of a winner and runner-up. The formulas determine a winner for each NA#. So if you have 280 NA#'s, there will be 280 results. Are you also trying to determine which candidate has the most votes across all of the NA#'s?
 
Upvote 0

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
So if you wanted to see a vote tabulation table created for 80 NA#'s, you would have NA-001 through NA-280 going down column A,
Sorry for the typo...I meant "...table created for 280 NA#'s..."

Also, please let me know about the answer to the last question. The point of that question is to understand whether you want to report back which single candidate received the most total votes assuming all of their votes were summed across all of the NA#'s. I don't see any indication in your original sheet that that is needed, but I wanted to confirm.
 
Last edited:
Upvote 0
So you have multiple two-letter codes: NA, PP, PS, PB, KP...is that correct?
correct.
Within each common two-letter code (say "NA"), you have a common set of candidates for each NA#, correct?
within each common 2-letter code (say NA) I will have multiple candidates with different names and different party names but there are 100% possibilities that some of the candidates will be marked are "Independent" meaning they will not be a part of any party but if he/she wins then the winner can join any party (I am not counting it in my sheet) (for me it will be Indepantant only)
so, let's say I have NA-001 - so the candidate's names and parties will be as below (just an example)
Name Party
John Wright PARTY-ABC
Joe Biden PARTY-DEF
Michael JR PARTY-GHI
Mark Obama Independent
Steven Clark Independent
Steven JR Independent

but there are possibilities that I will have another candidate with the same name (since we take only first and second names) but in different parties. so add 1 more name to the above list for NA-001
Steven JR PARTY-JKL

(((Steven JR Independent - Steven JR PARTY-JKL <<<< only the names are the same but different person and in different party)))

now let us assume the NA-002
Name Party
Michael Wright PARTY-ABC
Joel JR PARTY-DEF
Michael John PARTY-GHI
Mark White Independent
Steven John Independent
Steven Michael Independent

another scenario is that Michael Wright from party PARTY-ABC is participating in NA-002 but the same person can also participate in NA-003 etc

But are the sets of candidates different between any two two-letter codes. For example if Candidates named "a", "b", and "c" appear in all of the NA# groups, you would not find the same candidates "a", "b", and "c" in the PP# groups, correct? Are the candidates different between NA and PP and PS and...
The person who is participating from NA can also participate from any other NA and even multiple times. 2 3 4 5 6 (just assume up to 10 different NA)
person who is participating from NA, the same person can also be a part of PP PS PB KP
The person who is participating from any 2-letter code can be anywhere with multiple times

Are you also trying to determine which candidate has the most votes across all of the NA#'s?
no. not the candidates but I am calculating each party is having the most votes from the actual valid votes and then doing the % comparison (it will be in my dashboard)
 
Upvote 0
dashboard will appear like this:


1663691302540.png
 
Upvote 0
it will be a lot of work and I don't want to keep on disturbing you.
as I said, my initial sheet is working perfectly but the only problem is the condition check to mark the highest voters and the runner-up. I can ignore this as well but it will be easy to find that candidate when looking at the results.
so if you can only help me to fix the L & M condition check, then we can resolve this case.
thank you once again

1663691618238.png



Election Test-0005.xlsx
LM
21,0000.15%
3100,00015.04%
41,0000.15%
51,0000.15%
61,0000.15%
71,0000.15%
8120,00018.05%
91,0000.15%
101,0000.15%
111,0000.15%
121,0000.15%
13130,00019.55%
14140,00021.05%
15150,00022.56%
161,0000.15%
171,0000.15%
181,0000.15%
191,0000.15%
201,0000.15%
211,0000.15%
221,0000.15%
231,0000.15%
241,0000.15%
251,0000.15%
261,0000.15%
271,0000.15%
281,0000.15%
291,0000.15%
301,0000.15%
311,0000.15%
321,0000.15%
3310.00%
3410.00%
35160,00024.06%
361,0000.15%
37170,00025.56%
38140,00021.05%
39130,00019.55%
40120,00018.05%
41180,00027.07%
421,0000.15%
431,0000.15%
441,0000.15%
451,0000.15%
461,0000.15%
471,0000.15%
481,0000.15%
491,0000.15%
501,0000.15%
511,0000.15%
521,0000.15%
531,0000.15%
541,0000.15%
551,0000.15%
561,0000.15%
571,0000.15%
581,0000.15%
591,0000.15%
601,0000.15%
611,0000.15%
Election 2022 (MNA)
Cell Formulas
RangeFormula
M2M2=IF($L2="","",$L2/$H2)
M3:M31M3=IF($L3="","",$L3/$H$2)
M32:M61M32=IF(L32="","",L32/$H$2)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
L32:M61Expression=OR(L32=MAX(L$2:L$31),L32=LARGE(L$2:L$31,1))textNO
L32:M61Expression=OR(L32=MAX(L$2:L$31),L32=LARGE(L$2:L$31,2))textNO
L2:M31Expression=OR(L2=MAX(L$2:L$31),L2=LARGE(L$2:L$31,1))textNO
L2:M31Expression=OR(L2=MAX(L$2:L$31),L2=LARGE(L$2:L$31,2))textNO
 
Upvote 0
if we can use the unique 2-letter code in the condition check then it will be more than enough but if it's possible.
 
Upvote 0
There are some problems with your Conditional Formatting formulas. Let's take the first one as an example:
Excel Formula:
=OR(L32=MAX(L$2:L$31),L32=LARGE(L$2:L$31,1))
Note that the range L$2:L$31 is being examined...we want the max for range L$2:L$31 but the formula is checking whether L32 (not in the same range) is equal to the max. That isn't correct.
Another comment: the formula uses an OR condition, so if the largest or second largest values are found, the same action will be taken. That isn't what you want. My understanding is that you want the largest vote tally to be filled green and the 2nd largest to be filled red. So you would need two separate formulas to do this: one checks for the largest value, and the other formula checks for the 2nd largest value.
This formula illustrates why I think using merged cells and not including the two-letter code on each row for each candidate is a problem. You have no good way to construct a formula that will consider only the relevant votes for the NA# being considered. As your worksheet is currently structured, you would need two formulas for each NA# that look something like this:
Excel Formula:
=LARGE(L$2:L$31,1)=$L2
...if TRUE then fill cell green
Excel Formula:
=LARGE(L$2:L$31,2)=$L2
...if TRUE then fill cell red
...then for the next NA#, the conditional formatting would look like this:
Excel Formula:
=LARGE(L$32:L$61,1)=$L32
...if TRUE then fill cell green
Excel Formula:
=LARGE(L$32:L$61,2)=$L32
...if TRUE then fill cell red
This is tedious to maintain and very cumbersome. Every block having a common NA# needs to have its range declared in the formula. I wouldn't do it this way. And if the number of candidates can vary among the different NA#'s, you couldn't rely on a pattern.

Instead, I would recommend adding a column between columns I and J that shows the NA# for each candidate. Then you could write two Conditional Formatting formulas and apply them to the entire column for [Votes] and [% of Candidate Votes]. Those formulas would look like this:
Excel Formula:
=AGGREGATE(14,6,($M$2:$M$1000)/(($J$2:$J$1000=$J2)*($J2<>"")*($M2<>"")),1)=$M2
...if TRUE then fill cell green
Excel Formula:
=AGGREGATE(14,6,($M$2:$M$1000)/(($J$2:$J$1000=$J2)*($J2<>"")*($M2<>"")),2)=$M2
...if TRUE then fill cell red
These formulas look at the entire vote tabulation column (adjust the last row to cover the entire table) and confirm that the [Two-letter-#] column entry is not blank and the [Votes] column entry is not blank, then it aggregates all votes having a common [Two-letter-#] code and determines the largest (green) and 2nd largest (red) vote tally.
Mrexcel_20220917a.xlsx
JKLMN
1Two-letter-#Candidate NameParty NameVotes% Of Candidate Votes
2NA-001Candidate Name 0001Party Name AA10000.02311
3NA-001Candidate Name 0002Party Name AB5000.011555
4NA-001Candidate Name 0003Party Name AC24.62E-05
5NA-002Candidate Name 0004Party Name AD90000.207987
6NA-002Candidate Name 0005Party Name AE49.24E-05
7NA-002Candidate Name 0006Party Name AF27000.062396
8NA-002Candidate Name 0007Party Name AG60.000139
9NA-003Candidate Name 0008Party Name AH70.000162
10NA-003Candidate Name 0009Party Name AI27000.062396
11NA-003Candidate Name 0010Party Name AJ100.000231
12NA-003Candidate Name 0011Party Name AK110.000254
13NA-003Candidate Name 0012Party Name AL120.000277
14NA-003Candidate Name 0013Party Name AM130.0003
Election 2022 (MNA) (4)
Cell Formulas
RangeFormula
N2:N14N2=IF(M2="","",M2/$H$2)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
M2:N14Expression=AGGREGATE(14,6,($M$2:$M$1000)/(($J$2:$J$1000=$J2)*($J2<>"")*($M2<>"")),1)=$M2textNO
M2:N14Expression=AGGREGATE(14,6,($M$2:$M$1000)/(($J$2:$J$1000=$J2)*($J2<>"")*($M2<>"")),2)=$M2textNO
 
Upvote 0
perfect.... excellent work.

applied the last formulas after adding the NA# or each candidate and it's working as it should work.
thank you so much, dude. really appreciate it.

I am sharing the screenshot and a mini sheet. actually, I have tested in 10 records but just sharing the 3 records as a mini sheet.
there are green error arrows in O P Q R - could you please check these? (you can find them on the upper left edge of the cell O P Q R

also please test the mini sheet if I did everything perfectly.

best regards,


1663707567820.png





Election 2022.xlsx
EFGHIJKLMNOPQR
1Registered VotersTotal Cast VotesRejected VotesValid Cast Votes% Of Total Registered VotesCandidate NameParty NameVotes% Of Candidate VotesWinner's NameWinner PartyRunner up NameRunner up Party
2318,1503,0715002,5710.97%NA-001Candidate Name 0001Party Name AA100.39%Candidate Name 0012Party Name ALCandidate Name 0005Party Name AE
3NA-001Candidate Name 0002Party Name AB200.78%
4NA-001Candidate Name 0003Party Name AC2007.78%
5NA-001Candidate Name 0004Party Name AD401.56%
6NA-001Candidate Name 0005Party Name AE50019.45%
7NA-001Candidate Name 0006Party Name AF602.33%
8NA-001Candidate Name 0007Party Name AG702.72%
9NA-001Candidate Name 0008Party Name AH803.11%
10NA-001Candidate Name 0009Party Name AI903.50%
11NA-001Candidate Name 0010Party Name AJ1003.89%
12NA-001Candidate Name 0011Party Name AK1013.93%
13NA-001Candidate Name 0012Party Name AL60023.34%
14NA-001Candidate Name 0013Party Name AM00.00%
15NA-001Candidate Name 0014Party Name AN00.00%
16NA-001Candidate Name 0015Party Name AO00.00%
17NA-001Candidate Name 0016Party Name AP00.00%
18NA-001Candidate Name 0017Party Name AQ00.00%
19NA-001Candidate Name 0018Party Name AR00.00%
20NA-001Candidate Name 0019Party Name AS00.00%
21NA-001Candidate Name 0020Party Name AT00.00%
22NA-001Candidate Name 0021Party Name AU00.00%
23NA-001Candidate Name 0022Party Name AV00.00%
24NA-001Candidate Name 0023Party Name AW00.00%
25NA-001Candidate Name 0024Party Name AX00.00%
26NA-001Candidate Name 0025Party Name AY30011.67%
27NA-001Candidate Name 0026Party Name AZ00.00%
28NA-001Candidate Name 0027Party Name BA00.00%
29NA-001Candidate Name 0028Party Name BB00.00%
30NA-001Candidate Name 0029Party Name BC00.00%
31NA-001Candidate Name 0030Party Name BD40015.56%
321,5005001,000 NA-002Candidate Name 0001Party Name AA00.00%Candidate Name 0025Party Name AYCandidate Name 0012Party Name AL
33NA-002Candidate Name 0002Party Name AB00.00%
34NA-002Candidate Name 0003Party Name AC00.00%
35NA-002Candidate Name 0004Party Name AD00.00%
36NA-002Candidate Name 0005Party Name AE00.00%
37NA-002Candidate Name 0006Party Name AF00.00%
38NA-002Candidate Name 0007Party Name AG00.00%
39NA-002Candidate Name 0008Party Name AH00.00%
40NA-002Candidate Name 0009Party Name AI00.00%
41NA-002Candidate Name 0010Party Name AJ00.00%
42NA-002Candidate Name 0011Party Name AK00.00%
43NA-002Candidate Name 0012Party Name AL30011.67%
44NA-002Candidate Name 0013Party Name AM00.00%
45NA-002Candidate Name 0014Party Name AN00.00%
46NA-002Candidate Name 0015Party Name AO00.00%
47NA-002Candidate Name 0016Party Name AP1003.89%
48NA-002Candidate Name 0017Party Name AQ2007.78%
49NA-002Candidate Name 0018Party Name AR00.00%
50NA-002Candidate Name 0019Party Name AS00.00%
51NA-002Candidate Name 0020Party Name AT00.00%
52NA-002Candidate Name 0021Party Name AU00.00%
53NA-002Candidate Name 0022Party Name AV00.00%
54NA-002Candidate Name 0023Party Name AW00.00%
55NA-002Candidate Name 0024Party Name AX00.00%
56NA-002Candidate Name 0025Party Name AY40015.56%
57NA-002Candidate Name 0026Party Name AZ00.00%
58NA-002Candidate Name 0027Party Name BA00.00%
59NA-002Candidate Name 0028Party Name BB00.00%
60NA-002Candidate Name 0029Party Name BC00.00%
61NA-002Candidate Name 0030Party Name BD00.00%
62320,551500320,051 NA-003Candidate Name 0001Party Name AA00.00%Candidate Name 0004Party Name ADCandidate Name 0003Party Name AC
63NA-003Candidate Name 0002Party Name AB100.39%
64NA-003Candidate Name 0003Party Name AC20,000777.91%
65NA-003Candidate Name 0004Party Name AD300,00011668.61%
66NA-003Candidate Name 0005Party Name AE00.00%
67NA-003Candidate Name 0006Party Name AF00.00%
68NA-003Candidate Name 0007Party Name AG00.00%
69NA-003Candidate Name 0008Party Name AH00.00%
70NA-003Candidate Name 0009Party Name AI00.00%
71NA-003Candidate Name 0010Party Name AJ00.00%
72NA-003Candidate Name 0011Party Name AK00.00%
73NA-003Candidate Name 0012Party Name AL00.00%
74NA-003Candidate Name 0013Party Name AM00.00%
75NA-003Candidate Name 0014Party Name AN00.00%
76NA-003Candidate Name 0015Party Name AO00.00%
77NA-003Candidate Name 0016Party Name AP00.00%
78NA-003Candidate Name 0017Party Name AQ00.00%
79NA-003Candidate Name 0018Party Name AR00.00%
80NA-003Candidate Name 0019Party Name AS00.00%
81NA-003Candidate Name 0020Party Name AT00.00%
82NA-003Candidate Name 0021Party Name AU00.00%
83NA-003Candidate Name 0022Party Name AV00.00%
84NA-003Candidate Name 0023Party Name AW00.00%
85NA-003Candidate Name 0024Party Name AX200.78%
86NA-003Candidate Name 0025Party Name AY210.82%
87NA-003Candidate Name 0026Party Name AZ00.00%
88NA-003Candidate Name 0027Party Name BA00.00%
89NA-003Candidate Name 0028Party Name BB00.00%
90NA-003Candidate Name 0029Party Name BC00.00%
91NA-003Candidate Name 0030Party Name BD00.00%
Election 2022 (MNA)
Cell Formulas
RangeFormula
H2,H62,H32H2=SUM(M2:M31)
I2,I62,I32I2=IF(E2="","",F2/E2)
N2:N91N2=IF(M2="","",M2/$H$2)
O2,O62,O32O2=INDEX(K2:K31,MATCH(MAX(M2:M31),M2:M31,0))
P2,P62,P32P2=INDEX(L2:L31,MATCH(MAX(M2:M31),M2:M31,0))
Q2,Q62,Q32Q2=INDEX(K2:K31,MATCH(LARGE($M2:$M31,2),M2:M31,0))
R2,R62,R32R2=INDEX(L2:L31,MATCH(LARGE($M2:$M31,2),M2:M31,0))
F2,F62,F32F2=H2+G2
Cells with Conditional Formatting
CellConditionCell FormatStop If True
F32:F301Cell Value>$E$2textNO
F32:F301Cell Value>0textNO
H32:H301Cell Value>$E$2textNO
M3:N301Expression=AGGREGATE(14,6,($M$2:$M$1000)/(($J$2:$J$1000=$J3)*($J3<>"")*($M3<>"")),1)=$M3textNO
M3:N301Expression=AGGREGATE(14,6,($M$2:$M$1000)/(($J$2:$J$1000=$J3)*($J3<>"")*($M3<>"")),2)=$M3textNO
M2:N2Expression=AGGREGATE(14,6,($M$2:$M$1000)/(($J$2:$J$1000=$J2)*($J2<>"")*($M2<>"")),1)=$M2textNO
M2:N2Expression=AGGREGATE(14,6,($M$2:$M$1000)/(($J$2:$J$1000=$J2)*($J2<>"")*($M2<>"")),2)=$M2textNO
F2:F31Cell Value>$E$2textNO
F2:F31Cell Value>0textNO
H2:H31Cell Value>$E$2textNO
 
Upvote 0
defenitely I need help while preparing the dashboard.
let me start entering the dummy data for all NA# PP# PS# PB# KP# and then I will start the dummy voting system, and based on that, I will prepare the dashboard. but before that, you can verify the above mini sheet and clear the error, please.
 
Upvote 0
If you examine my suggested worksheet in post #16, you will see that I recommend finding the [Valid Cast Votes] (col. H), and the [Winner's Name] (col. O), [Winner Party] (col. P), [Runner up Name] (col. Q), and [Runner up Party] (col. R) differently. The reason for a different approach is the same one described in post #27...
This is tedious to maintain and very cumbersome. Every block having a common NA# needs to have its range declared in the formula. I wouldn't do it this way. And if the number of candidates can vary among the different NA#'s, you couldn't rely on a pattern.
So instead of finding the [Winner's Name} with this:
Excel Formula:
=INDEX(K2:K31,MATCH(MAX(M2:M31),M2:M31,0))
...and then having to worry about adjusting ranges (the K2:K31 and M2:M31) in every section where the two-letter # combination changes, it makes more sense to use the newly added column J to perform a filter-type operation on the full column. That way a single formula can be used without adjusting the ranges. This idea is applied everywhere else to avoid specifying two-letter #-specific ranges. Assuming you keep the merged rows in column A to show the two-letter # for each particular block (again, I don't recommend this, but that seems to be your preference), then the first block would look something like this:
Mrexcel_20220917a.xlsx
AEFGHIJKLMNOPQR
1NA # (2018)Registered VotersTotal Cast VotesRejected VotesValid Cast Votes% Of Total Registered Votes2-ltr-#Candidate NameParty NameVotes% Of Candidate VotesWinner's NameWinner PartyRunner up NameRunner up Party
2NA-001318150320750027070.01008015NA-001Candidate Name 0001Party Name AA100.37%Candidate Name 0012Party Name ALCandidate Name 0005Party Name AE
3NA-001Candidate Name 0002Party Name AB200.74%
4NA-001Candidate Name 0003Party Name AC2007.39%
5NA-001Candidate Name 0004Party Name AD401.48%
6NA-001Candidate Name 0005Party Name AE50018.47%
7NA-001Candidate Name 0006Party Name AF602.22%
8NA-001Candidate Name 0007Party Name AG702.59%
9NA-001Candidate Name 0008Party Name AH802.96%
10NA-001Candidate Name 0009Party Name AI903.32%
11NA-001Candidate Name 0010Party Name AJ1003.69%
12NA-001Candidate Name 0011Party Name AK1013.73%
13NA-001Candidate Name 0012Party Name AL60022.16%
14NA-001Candidate Name 0013Party Name AM10.04%
15NA-001Candidate Name 0014Party Name AN20.07%
16NA-001Candidate Name 0015Party Name AO30.11%
17NA-001Candidate Name 0016Party Name AP40.15%
18NA-001Candidate Name 0017Party Name AQ50.18%
19NA-001Candidate Name 0018Party Name AR60.22%
20NA-001Candidate Name 0019Party Name AS70.26%
21NA-001Candidate Name 0020Party Name AT80.30%
22NA-001Candidate Name 0021Party Name AU90.33%
23NA-001Candidate Name 0022Party Name AV100.37%
24NA-001Candidate Name 0023Party Name AW110.41%
25NA-001Candidate Name 0024Party Name AX120.44%
26NA-001Candidate Name 0025Party Name AY30011.08%
27NA-001Candidate Name 0026Party Name AZ130.48%
28NA-001Candidate Name 0027Party Name BA140.52%
29NA-001Candidate Name 0028Party Name BB150.55%
30NA-001Candidate Name 0029Party Name BC160.59%
31NA-001Candidate Name 0030Party Name BD40014.78%
Sheet4
Cell Formulas
RangeFormula
F2F2=IF(H2="","",H2+G2)
H2H2=IF(COUNTIFS($J:$J,$J2,$M:$M,"<>")=COUNTIF($J:$J,$J2),SUMIF($J:$J,$A2,$M:$M),"")
I2I2=IF(OR(E2="",F2=""),"",F2/E2)
N2:N31N2=IF(COUNTIFS($J:$J,$J2,$M:$M,"<>")=COUNTIF($J:$J,$J2),$M2/SUMIF($J:$J,$J2,$M:$M),"")
O2O2=IF(COUNTIFS($J:$J,$J2,$M:$M,"<>")=COUNTIF($J:$J,$J2),INDEX($K$2:$K$1000,MATCH(1,($J$2:$J$1000=$A2)*($M$2:$M$1000=LARGE(($M$2:$M$1000)*($J$2:$J$1000=$A2),1)),0)),"")
P2P2=IF(COUNTIFS($J:$J,$J2,$M:$M,"<>")=COUNTIF($J:$J,$J2),INDEX($L$2:$L$1000,MATCH(1,($J$2:$J$1000=$A2)*($M$2:$M$1000=LARGE(($M$2:$M$1000)*($J$2:$J$1000=$A2),1)),0)),"")
Q2Q2=IF(COUNTIFS($J:$J,$J2,$M:$M,"<>")=COUNTIF($J:$J,$J2),INDEX($K$2:$K$1000,MATCH(1,($J$2:$J$1000=$A2)*($M$2:$M$1000=LARGE(($M$2:$M$1000)*($J$2:$J$1000=$A2),2)),0)),"")
R2R2=IF(COUNTIFS($J:$J,$J2,$M:$M,"<>")=COUNTIF($J:$J,$J2),INDEX($L$2:$L$1000,MATCH(1,($J$2:$J$1000=$A2)*($M$2:$M$1000=LARGE(($M$2:$M$1000)*($J$2:$J$1000=$A2),2)),0)),"")
Cells with Conditional Formatting
CellConditionCell FormatStop If True
M2:N31Expression=IF(COUNTIFS($J:$J,$J2,$M:$M,"<>")=COUNTIF($J:$J,$J2),AGGREGATE(14,6,($M$2:$M$1000)/($J$2:$J$1000=$J2),1)=$M2,FALSE)textNO
M2:N31Expression=IF(COUNTIFS($J:$J,$J2,$M:$M,"<>")=COUNTIF($J:$J,$J2),AGGREGATE(14,6,($M$2:$M$1000)/($J$2:$J$1000=$J2),2)=$M2,FALSE)textNO

Note that the formulas have been revised to perform some checking that vote tallies have been entered for an entire two-letter # block before returning results. This is to avoid errors and misunderstandings should someone look at an incomplete voting tabulation and see a winner/runner-up before all of the votes have been entered. As the table grows in length, you will need to adjust these formulas to cover the entire length of the table (it's okay if the formula refers to rows far below the end of the data)...but I expect the references to row 1000 will change in the in-cell formulas and in the Data Validation formulas.

You will want to try out this worksheet with a large set of data to see if it behaves as expected and if the performance is too slow. The conditional formatting and the checks to confirm that data have been entered before rendering a result may adversely affect performance.

Regarding the error messages, if you click on those cells with the green flags, you will see a yellow symbol with a dropdown arrow. Selecting the dropdown reveals the error is due to "Formula Omits Adjacent Cells". This is an artifact of your choice to use merged cells. The formulas are in cells O2:R2 (although I have to scroll all the way down to rows 15:17 to see the formula results); and the formulas refer to ranges in rows 2:31...and then there is nothing below the formula until row 32, where the next group of formulas is found. There is nothing inherently wrong that the errors are flagging...they are simply calling attention to the fact that cells around the formula do not have formulas in them. If you continue to see them, you can go back into each one, click the dropdown I described and select the option to ignore this error.
also please test the mini sheet if I did everything perfectly
I hesitate to say that everything is done perfectly. I think the worksheet will prove to be difficult to use and difficult to extract summary information from, but you or others will need to make that determination. That said, I believe the formulas return the correct results, are reasonably robust, and handle the issues created by the merged cells satisfactorily. I suppose if you wanted a summary table of results that did not include the vote tabulation table (so that the results were more consolidated), you could either apply column auto-filters to hide the blank rows (created by the merged cells), or use another set of formulas to extract the first row of every common two-letter code block...but that seems like more work than necessary.
 
Upvote 0

Forum statistics

Threads
1,215,029
Messages
6,122,757
Members
449,094
Latest member
dsharae57

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