calculating stock market bonus shares

mwvirk

Active Member
Joined
Mar 2, 2011
Messages
295
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)
 
What version of Excel are you using? Please update your profile to show that, as some functions available in Excel 365 might prove useful, either now or in the future...so displaying your version helps others identify solutions that might work better for you.

One thing that jumps out is the extensive use of merged cells in columns A:I and N:Y. Generally it's a bad idea to use them, especially when formulas are involved. Some formulas misbehave with merged cells and it becomes difficult to follow what the formula is doing, Additionally, table filtering and sorting will not be possible. Two other issues:
  1. The column P formula uses a fixed reference:
    Excel Formula:
    LARGE($L$2:$L$31,2)
    This fixed reference pointing to $L$2:$L$31 will be carried forward to other record sets when you copy and paste. You probably want a relative reference, such as
    Excel Formula:
    LARGE(L2:L31,2)
  2. Same for column Q formula
Let me know about your Excel version. I'm thinking that a flat table might be more robust.
Are you opposed to multiple tables? One table would log voting region (districts, precincts, or provinces) statistics. Another logs statistics for candidates, and another summarizes winners by voting region. That way you wouldn't need merged cells, and you would avoid a lot of redundant information in a large table (which is what will happen if the current merged cell information is copied throughout each "province" block to eliminate the merged cells).
Thanks again Krice,
i have updated my profit with the Office (2016) & OS version (Windows)
i tried using the formulas without '$' and it's still not helping when I copy the first record to downward.
unfortunately i cannot use XL2BB in my office computer (it's blocked)
i will update the mini sheet later today from PC or if there is any other way to share the file?
 
Upvote 0

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
1663492235336.png


i am sharing the screenshot. if you look at the highlighted cells (L35 to L41) the condition format is not working. the highest number is 160,000 and it should be marked as GREEN but it's marking the runner-up (140,000) as GREEN which should be actually RED
 
Upvote 0
but if you look at row N O P Q, these are showing the correct winner & part name as well as the correct runner-up and part name.
 
Upvote 0
What version of Excel are you using? Please update your profile to show that, as some functions available in Excel 365 might prove useful, either now or in the future...so displaying your version helps others identify solutions that might work better for you.

One thing that jumps out is the extensive use of merged cells in columns A:I and N:Y. Generally it's a bad idea to use them, especially when formulas are involved. Some formulas misbehave with merged cells and it becomes difficult to follow what the formula is doing, Additionally, table filtering and sorting will not be possible. Two other issues:
  1. The column P formula uses a fixed reference:
    Excel Formula:
    LARGE($L$2:$L$31,2)
    This fixed reference pointing to $L$2:$L$31 will be carried forward to other record sets when you copy and paste. You probably want a relative reference, such as
    Excel Formula:
    LARGE(L2:L31,2)
  2. Same for column Q formula
Let me know about your Excel version. I'm thinking that a flat table might be more robust.
Are you opposed to multiple tables? One table would log voting region (districts, precincts, or provinces) statistics. Another logs statistics for candidates, and another summarizes winners by voting region. That way you wouldn't need merged cells, and you would avoid a lot of redundant information in a large table (which is what will happen if the current merged cell information is copied throughout each "province" block to eliminate the merged cells).


Election Test-0000.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXY
1NA # (2018)ProvinceNA # (2013)Seat NameRegistered VotersTotal Cast VotesRejected VotesValid Cast Votes% Of Total Registered VotesCandidate NameParty NameVotes% Of Candidate VotesWinner's NameWinner PartyRunner up NameRunner up PartyPrevious Winner's Name In 2018Previous Party Name In 2018
2NA-001Province-1Name-001Area-001318,150521,0005,000516,000163.76%Candidate Name 0001Party Name AA1,0000.19%Candidate Name 0013Party Name AMCandidate Name 0012Party Name AL11221122112211221122
3Candidate Name 0002Party Name AB100,00019.38%
4Candidate Name 0003Party Name AC1,0000.19%
5Candidate Name 0004Party Name AD1,0000.19%
6Candidate Name 0005Party Name AE1,0000.19%
7Candidate Name 0006Party Name AF1,0000.19%
8Candidate Name 0007Party Name AG120,00023.26%
9Candidate Name 0008Party Name AH1,0000.19%
10Candidate Name 0009Party Name AI1,0000.19%
11Candidate Name 0010Party Name AJ1,0000.19%
12Candidate Name 0011Party Name AK1,0000.19%
13Candidate Name 0012Party Name AL130,00025.19%
14Candidate Name 0013Party Name AM140,00027.13%
15Candidate Name 0014Party Name AN1,0000.19%
16Candidate Name 0015Party Name AO1,0000.19%
17Candidate Name 0016Party Name AP1,0000.19%
18Candidate Name 0017Party Name AQ1,0000.19%
19Candidate Name 0018Party Name AR1,0000.19%
20Candidate Name 0019Party Name AS1,0000.19%
21Candidate Name 0020Party Name AT1,0000.19%
22Candidate Name 0021Party Name AU1,0000.19%
23Candidate Name 0022Party Name AV1,0000.19%
24Candidate Name 0023Party Name AW1,0000.19%
25Candidate Name 0024Party Name AX1,0000.19%
26Candidate Name 0025Party Name AY1,0000.19%
27Candidate Name 0026Party Name AZ1,0000.19%
28Candidate Name 0027Party Name BA1,0000.19%
29Candidate Name 0028Party Name BB1,0000.19%
30Candidate Name 0029Party Name BC1,0000.19%
31Candidate Name 0030Party Name BD1,0000.19%
32NA-002Province-1Name-002Area-002318,150611,0005,000606,000192.05%Candidate Name 0001Party Name AA1,0000.19%Candidate Name 0004Party Name ADCandidate Name 0002Party Name AB
33Candidate Name 0002Party Name AB150,00029.07%
34Candidate Name 0003Party Name AC130,00025.19%
35Candidate Name 0004Party Name AD160,00031.01%
36Candidate Name 0005Party Name AE1,0000.19%
37Candidate Name 0006Party Name AF1,0000.19%
38Candidate Name 0007Party Name AG140,00027.13%
39Candidate Name 0008Party Name AH1,0000.19%
40Candidate Name 0009Party Name AI1,0000.19%
41Candidate Name 0010Party Name AJ1,0000.19%
42Candidate Name 0011Party Name AK1,0000.19%
43Candidate Name 0012Party Name AL1,0000.19%
44Candidate Name 0013Party Name AM1,0000.19%
45Candidate Name 0014Party Name AN1,0000.19%
46Candidate Name 0015Party Name AO1,0000.19%
47Candidate Name 0016Party Name AP1,0000.19%
48Candidate Name 0017Party Name AQ1,0000.19%
49Candidate Name 0018Party Name AR1,0000.19%
50Candidate Name 0019Party Name AS1,0000.19%
51Candidate Name 0020Party Name AT1,0000.19%
52Candidate Name 0021Party Name AU1,0000.19%
53Candidate Name 0022Party Name AV1,0000.19%
54Candidate Name 0023Party Name AW1,0000.19%
55Candidate Name 0024Party Name AX1,0000.19%
56Candidate Name 0025Party Name AY1,0000.19%
57Candidate Name 0026Party Name AZ1,0000.19%
58Candidate Name 0027Party Name BA1,0000.19%
59Candidate Name 0028Party Name BB1,0000.19%
60Candidate Name 0029Party Name BC1,0000.19%
61Candidate Name 0030Party Name BD1,0000.19%
62NA-003Province-1Name-003Area-003Candidate Name 0001Party Name AA
63Candidate Name 0002Party Name AB
64Candidate Name 0003Party Name AC
65Candidate Name 0004Party Name AD
66Candidate Name 0005Party Name AE
67Candidate Name 0006Party Name AF
68Candidate Name 0007Party Name AG
69Candidate Name 0008Party Name AH
70Candidate Name 0009Party Name AI
71Candidate Name 0010Party Name AJ
72Candidate Name 0011Party Name AK
73Candidate Name 0012Party Name AL
74Candidate Name 0013Party Name AM
75Candidate Name 0014Party Name AN
76Candidate Name 0015Party Name AO
77Candidate Name 0016Party Name AP
78Candidate Name 0017Party Name AQ
79Candidate Name 0018Party Name AR
80Candidate Name 0019Party Name AS
81Candidate Name 0020Party Name AT
82Candidate Name 0021Party Name AU
83Candidate Name 0022Party Name AV
84Candidate Name 0023Party Name AW
85Candidate Name 0024Party Name AX
86Candidate Name 0025Party Name AY
87Candidate Name 0026Party Name AZ
88Candidate Name 0027Party Name BA
89Candidate Name 0028Party Name BB
90Candidate Name 0029Party Name BC
91Candidate Name 0030Party Name BD
Election 2022 (MNA)
Cell Formulas
RangeFormula
H2,H32H2=SUM(L2:L31)
I2,I32I2=IF(E2="","",F2/E2)
M2:M61M2=IF(L2="","",L2/$H$2)
N2,N32N2=INDEX(J2:J31,MATCH(MAX(L2:L31),L2:L31,0))
O2,O32O2=INDEX(K2:K31,MATCH(MAX(L2:L31),L2:L31,0))
P2,P32P2=INDEX(J2:J31,MATCH(LARGE(L2:L31,2),L2:L31,0))
Q2,Q32Q2=INDEX(K2:K31,MATCH(LARGE(L2:L31,2),L2:L31,0))
F2,F32F2=H2+G2
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
F32:F61Cell Value>$E$2textNO
F32:F61Cell Value>0textNO
H32:H61Cell Value>$E$2textNO
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
F2:F31Cell Value>$E$2textNO
F2:F31Cell Value>0textNO
H2:H31Cell Value>$E$2textNO
 
Upvote 0
i think problem is only in condition check formating in L & M rows
 
Upvote 0
Here is an example of a different format that I mentioned. To avoid the very long blocks for each NA# and the merged cells, the idea here is to:
  1. Construct a single list of Candidate Names and the associated Party Name in W2:X50 (this could be longer, but the formulas are set up to accommodate that many...alternatively, you could convert this to an official Excel table, which would dynamically resize itself).
  2. Construct the descriptions of the voting regions/provinces/districts (not sure what these are called, but I'm referring to columns A:E and G). You may want to switch the F:G positions so that initial inputs would be columns A:F (the last being Rejected Votes)...because everything to the right is formula-based.
  3. Helper cells in Z1:AA3 count the number of voting regions/provinces/districts and the number of candidates. Based on these two counts, we know the vote tabulation table needs to have a specific number of rows given by (#regions) * (#candidates), so formulas in columns Q:S automatically construct the left side of the vote tabulation table...just pull the formulas in Q:S down until blanks are produced. The NA#'s and candidate information automatically populates the table.
  4. When votes are entered in column T, column U will calculate and information for the winner and runner up will be determined by formulas in the main table. Importantly, these formulas do not reference a specific range tied to an NA#. Instead the formulas reference the entire voter tabulation table and use logic-based matching to consider only the relevant rows.
  5. The issue you described earlier is a Conditional Formatting problem, and I suspect the formula used on your worksheet needs to be revised. In this example, I've added two Conditional Formatting rules to turn the winner vote tally green and the runner up tally red.
I have all of these on the same worksheet, but I'm showing it in sections for easier viewing:
The main table:
Mrexcel_20220918_mwvirk.xlsx
ABCDEFGHIJKLMNO
1NA # (2018)ProvinceNA # (2013)Seat NameRegistered VotersTotal Cast VotesRejected VotesValid Cast Votes% Of Total Registered VotesWinner's NameWinner PartyRunner up NameRunner up PartyPrevious Winner's Name In 2018Previous Party Name In 2018
2NA-001Province-1Name-001Area-001318150209205000159206.576%Candidate Name 0004Party Name ADCandidate Name 0009Party Name AI
3NA-002Province-1Name-002Area-002126126 Candidate Name 0009Party Name AICandidate Name 0008Party Name AH
4NA-003Province-1Name-003Area-0032815628156 Candidate Name 0009Party Name AICandidate Name 0006Party Name AF
5NA-004Province-2Name-004Area-0046417064170 Candidate Name 0004Party Name ADCandidate Name 0002Party Name AB
6NA-005Province-2Name-005Area-0054685646856 Candidate Name 0007Party Name AGCandidate Name 0008Party Name AH
Election 2022 (MNA)_v2
Cell Formulas
RangeFormula
H2:H6H2=SUMIF($Q:$Q,$A2,$T:$T)
I2:I6I2=IF($E2="","",$F2/$E2)
J2:J6J2=INDEX($R$2:$R$1000,AGGREGATE(15,6,(ROW($2:$1000)-ROW($2:$2)+1)/(($Q$2:$Q$1000=$A2)*($T$2:$T$1000=(LARGE(($T$2:$T$1000)*($Q$2:$Q$1000=$A2),1)))),1))
K2:K6K2=INDEX($S$2:$S$1000,AGGREGATE(15,6,(ROW($2:$1000)-ROW($2:$2)+1)/(($Q$2:$Q$1000=$A2)*($T$2:$T$1000=(LARGE(($T$2:$T$1000)*($Q$2:$Q$1000=$A2),1)))),1))
L2:L6L2=INDEX($R$2:$R$1000,AGGREGATE(15,6,(ROW($2:$1000)-ROW($2:$2)+1)/(($Q$2:$Q$1000=$A2)*($T$2:$T$1000=(LARGE(($T$2:$T$1000)*($Q$2:$Q$1000=$A2),2)))),1))
M2:M6M2=INDEX($S$2:$S$1000,AGGREGATE(15,6,(ROW($2:$1000)-ROW($2:$2)+1)/(($Q$2:$Q$1000=$A2)*($T$2:$T$1000=(LARGE(($T$2:$T$1000)*($Q$2:$Q$1000=$A2),2)))),1))
F2:F6F2=SUM($G2:$H2)

The vote tabulation table (only a portion shown):
Mrexcel_20220918_mwvirk.xlsx
QRSTU
1NA # (2018)Candidate NameParty NameVotes% Of Candidate Votes
2NA-001Candidate Name 0001Party Name AA10006.281%
3NA-001Candidate Name 0002Party Name AB5003.141%
4NA-001Candidate Name 0003Party Name AC20.013%
5NA-001Candidate Name 0004Party Name AD900056.533%
6NA-001Candidate Name 0005Party Name AE40.025%
7NA-001Candidate Name 0006Party Name AF270016.960%
8NA-001Candidate Name 0007Party Name AG60.038%
9NA-001Candidate Name 0008Party Name AH70.044%
10NA-001Candidate Name 0009Party Name AI270116.966%
11NA-002Candidate Name 0001Party Name AA107.937%
12NA-002Candidate Name 0002Party Name AB118.730%
13NA-002Candidate Name 0003Party Name AC129.524%
14NA-002Candidate Name 0004Party Name AD1310.317%
15NA-002Candidate Name 0005Party Name AE1411.111%
16NA-002Candidate Name 0006Party Name AF1511.905%
17NA-002Candidate Name 0007Party Name AG1612.698%
18NA-002Candidate Name 0008Party Name AH1713.492%
19NA-002Candidate Name 0009Party Name AI1814.286%
20NA-003Candidate Name 0001Party Name AA190.067%
21NA-003Candidate Name 0002Party Name AB200.071%
22NA-003Candidate Name 0003Party Name AC210.075%
23NA-003Candidate Name 0004Party Name AD220.078%
24NA-003Candidate Name 0005Party Name AE230.082%
25NA-003Candidate Name 0006Party Name AF10003.552%
26NA-003Candidate Name 0007Party Name AG250.089%
27NA-003Candidate Name 0008Party Name AH260.092%
28NA-003Candidate Name 0009Party Name AI2700095.894%
29NA-004Candidate Name 0001Party Name AA280.044%
30NA-004Candidate Name 0002Party Name AB2000031.167%
Election 2022 (MNA)_v2
Cell Formulas
RangeFormula
Q2:Q30Q2=IF(ROWS(Q$2:Q2)>$AA$2*$AA$3,"",INDEX($A$2:$A$50,INT((ROWS(Q$2:Q2)-1)/$AA$3)+1))
R2:R30R2=IF(ROWS(Q$2:Q2)>$AA$2*$AA$3,"",INDEX($W$2:$W$50,MOD(ROWS(Q$2:Q2)-1,$AA$3)+1))
S2:S30S2=IF(ROWS(Q$2:Q2)>$AA$2*$AA$3,"",INDEX($X$2:$X$50,MOD(ROWS(R$2:R2)-1,$AA$3)+1))
U2:U30U2=IF(T2="","",T2/SUMIF(Q:Q,Q2,T:T))
Cells with Conditional Formatting
CellConditionCell FormatStop If True
T2:U50Expression=AGGREGATE(14,6,($T$2:$T$1000)/(($Q$2:$Q$1000=$Q2)*($Q2<>"")*($T2<>"")),2)=$T2textNO
T2:U50Expression=AGGREGATE(14,6,($T$2:$T$1000)/(($Q$2:$Q$1000=$Q2)*($Q2<>"")*($T2<>"")),1)=$T2textNO

The candidate information table and helper/counter table:
Mrexcel_20220918_mwvirk.xlsx
WXYZAA
1Candidate NameParty NameHelper Counts for Convenience
2Candidate Name 0001Party Name AANumber of Voting Districts/Precincts5
3Candidate Name 0002Party Name ABNumber of Candidates9
4Candidate Name 0003Party Name AC
5Candidate Name 0004Party Name AD
6Candidate Name 0005Party Name AE
7Candidate Name 0006Party Name AF
8Candidate Name 0007Party Name AG
9Candidate Name 0008Party Name AH
10Candidate Name 0009Party Name AI
11
Election 2022 (MNA)_v2
Cell Formulas
RangeFormula
AA2AA2=COUNTA(A2:A1000)
AA3AA3=COUNTA(W2:W1000)

The workbook is available here for convenience:
 
Upvote 0
hello KRice, I really appreciate for giving me your time and sharing your remarkable work. the solution provided in your last post looks very difficult and I am sure you must have spent a lot of time resolving it. I know it must have taken a lot of time. please note that my knowledge of excel is minimal. in my mini sheet, I have shared 3 records but actually, my worksheet has almost 950 records. I have to split these 950 into 2 sheets to divide the category. so 300 will go in 1 sheet and the remaining 650 in another sheet. In the end, I will have a combined dashboard.
At this moment, I am not sure how many candidates will be in 1 record. Based on the confirmation, I have to add/remove the entries.
The logic used in your sheet is really looking excellent but due to my limited knowledge, I don't think I can input the actual record correctly and at that moment I will not have time to revise or recreate a new worksheet.

I don't understand the purpose of helper cells and cell W:X how can I add all 950x30 candidates where the name might be the same in many locations? honestly, it looks great but It's very difficult for me to understand.

there are 2 options:
1 if you can guide me on how to add or remove the candidates without impacting the entire sheet. in your R:S I can add more candidates if I add them in W:X but in your Q I cannot add a new NA # and if I add candidates having the same name then check the below screenshot, then J, K, L, M are giving error.

1663623330678.png


Other option is, if I can share the actual sheet in private and you can add all records as per your technique and I will do the data entry. but again this will not help me in sheet-2 and dashboard.


so, i am sharing my actual sheet again but this time we will not merge the cells. i have noticed that it will still OK although i have to paste the formula manually.
but still the condition check is not working.

i have another idea, may be this could help us. the value in row A & D are unique. can we use it to solve thge condition check issue and might be used in other rows as well if needed.
e.g. the condition check i am using in having a formula/ may be you can amend this formula and use the unique rows?

i am sharing the mini sheet again after removing the merged cells

(i have removed from rows which are not having significant data. actually it will be input later to check the last year winners)


Election Test-0005.xlsx
ABCDEFGHIJKLMNOPQ
1NA # (2018)ProvinceNA # (2013)Seat NameRegistered VotersTotal Cast VotesRejected VotesValid Cast Votes% Of Total Registered VotesCandidate NameParty NameVotes% Of Candidate VotesWinner's NameWinner PartyRunner up NameRunner up Party
2NA-001Province-1Name-001Area-001318,150670,0005,000665,000210.59%Candidate Name 0001Party Name AA1,0000.15%Candidate Name 0014Party Name ANCandidate Name 0013Party Name AM
3Candidate Name 0002Party Name AB100,00015.04%
4Candidate Name 0003Party Name AC1,0000.15%
5Candidate Name 0004Party Name AD1,0000.15%
6Candidate Name 0005Party Name AE1,0000.15%
7Candidate Name 0006Party Name AF1,0000.15%
8Candidate Name 0007Party Name AG120,00018.05%
9Candidate Name 0008Party Name AH1,0000.15%
10Candidate Name 0009Party Name AI1,0000.15%
11Candidate Name 0010Party Name AJ1,0000.15%
12Candidate Name 0011Party Name AK1,0000.15%
13Candidate Name 0012Party Name AL130,00019.55%
14Candidate Name 0013Party Name AM140,00021.05%
15Candidate Name 0014Party Name AN150,00022.56%
16Candidate Name 0015Party Name AO1,0000.15%
17Candidate Name 0016Party Name AP1,0000.15%
18Candidate Name 0017Party Name AQ1,0000.15%
19Candidate Name 0018Party Name AR1,0000.15%
20Candidate Name 0019Party Name AS1,0000.15%
21Candidate Name 0020Party Name AT1,0000.15%
22Candidate Name 0021Party Name AU1,0000.15%
23Candidate Name 0022Party Name AV1,0000.15%
24Candidate Name 0023Party Name AW1,0000.15%
25Candidate Name 0024Party Name AX1,0000.15%
26Candidate Name 0025Party Name AY1,0000.15%
27Candidate Name 0026Party Name AZ1,0000.15%
28Candidate Name 0027Party Name BA1,0000.15%
29Candidate Name 0028Party Name BB1,0000.15%
30Candidate Name 0029Party Name BC1,0000.15%
31Candidate Name 0030Party Name BD1,0000.15%
32NA-002Province-1Name-002Area-002318,150927,0025,000922,002291.37%Candidate Name 0001Party Name AA1,0000.15%Candidate Name 0010Party Name AJCandidate Name 0006Party Name AF
33Candidate Name 0002Party Name AB10.00%
34Candidate Name 0003Party Name AC10.00%
35Candidate Name 0004Party Name AD160,00024.06%
36Candidate Name 0005Party Name AE1,0000.15%
37Candidate Name 0006Party Name AF170,00025.56%
38Candidate Name 0007Party Name AG140,00021.05%
39Candidate Name 0008Party Name AH130,00019.55%
40Candidate Name 0009Party Name AI120,00018.05%
41Candidate Name 0010Party Name AJ180,00027.07%
42Candidate Name 0011Party Name AK1,0000.15%
43Candidate Name 0012Party Name AL1,0000.15%
44Candidate Name 0013Party Name AM1,0000.15%
45Candidate Name 0014Party Name AN1,0000.15%
46Candidate Name 0015Party Name AO1,0000.15%
47Candidate Name 0016Party Name AP1,0000.15%
48Candidate Name 0017Party Name AQ1,0000.15%
49Candidate Name 0018Party Name AR1,0000.15%
50Candidate Name 0019Party Name AS1,0000.15%
51Candidate Name 0020Party Name AT1,0000.15%
52Candidate Name 0021Party Name AU1,0000.15%
53Candidate Name 0022Party Name AV1,0000.15%
54Candidate Name 0023Party Name AW1,0000.15%
55Candidate Name 0024Party Name AX1,0000.15%
56Candidate Name 0025Party Name AY1,0000.15%
57Candidate Name 0026Party Name AZ1,0000.15%
58Candidate Name 0027Party Name BA1,0000.15%
59Candidate Name 0028Party Name BB1,0000.15%
60Candidate Name 0029Party Name BC1,0000.15%
61Candidate Name 0030Party Name BD1,0000.15%
62NA-003Province-1Name-003Area-003Candidate Name 0001Party Name AA101.504E-05Candidate Name 0030Party Name BDCandidate Name 0029Party Name BC
63Candidate Name 0002Party Name AB203.008E-05
64Candidate Name 0003Party Name AC304.511E-05
65Candidate Name 0004Party Name AD406.015E-05
66Candidate Name 0005Party Name AE507.519E-05
67Candidate Name 0006Party Name AF609.023E-05
68Candidate Name 0007Party Name AG700.0001053
69Candidate Name 0008Party Name AH800.0001203
70Candidate Name 0009Party Name AI900.0001353
71Candidate Name 0010Party Name AJ1000.0001504
72Candidate Name 0011Party Name AK1100.0001654
73Candidate Name 0012Party Name AL1200.0001805
74Candidate Name 0013Party Name AM1300.0001955
75Candidate Name 0014Party Name AN1400.0002105
76Candidate Name 0015Party Name AO1500.0002256
77Candidate Name 0016Party Name AP1600.0002406
78Candidate Name 0017Party Name AQ1700.0002556
79Candidate Name 0018Party Name AR1800.0002707
80Candidate Name 0019Party Name AS1900.0002857
81Candidate Name 0020Party Name AT2000.0003008
82Candidate Name 0021Party Name AU2100.0003158
83Candidate Name 0022Party Name AV2200.0003308
84Candidate Name 0023Party Name AW2300.0003459
85Candidate Name 0024Party Name AX2400.0003609
86Candidate Name 0025Party Name AY2500.0003759
87Candidate Name 0026Party Name AZ2600.000391
88Candidate Name 0027Party Name BA2700.000406
89Candidate Name 0028Party Name BB2800.0004211
90Candidate Name 0029Party Name BC2900.0004361
91Candidate Name 0030Party Name BD3000.0004511
Election 2022 (MNA)
Cell Formulas
RangeFormula
F2F2=$H2+$G2
H2H2=SUM($L2:$L31)
I2I2=IF($E2="","",$F2/$E2)
N2,N62,N32N2=INDEX($J2:$J31,MATCH(MAX($L2:$L31),$L2:$L31,0))
O2O2=INDEX($K$2:$K31,MATCH(MAX($L2:$L31),$L2:$L31,0))
P2P2=INDEX($J2:$J31,MATCH(LARGE($L2:$L31,2),$L2:$L31,0))
Q2Q2=INDEX($K2:$K31,MATCH(LARGE($L2:$L31,2),$L2:$L31,0))
F32F32=H32+G32
H32H32=SUM(L32:L61)
I32I32=IF(E32="","",F32/E32)
O32,O62O32=INDEX(K32:K61,MATCH(MAX(L32:L61),L32:L61,0))
P32,P62P32=INDEX(J32:J61,MATCH(LARGE(L32:L61,2),L32:L61,0))
Q32,Q62Q32=INDEX(K32:K61,MATCH(LARGE(L32:L61,2),L32:L61,0))
M2M2=IF($L2="","",$L2/$H2)
M3:M31M3=IF($L3="","",$L3/$H$2)
M32:M91M32=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
F32:F61Cell Value>$E$2textNO
F32:F61Cell Value>0textNO
H32:H61Cell Value>$E$2textNO
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
F2:F31Cell Value>$E$2textNO
F2:F31Cell Value>0textNO
H2:H31Cell Value>$E$2textNO



please take your time and work on this when you are free.
once again I am thankful for your excellent guidenace.

Regards,
MWVirk
 
Upvote 0
my worksheet has almost 950 records. I have to split these 950 into 2 sheets to divide the category. so 300 will go in 1 sheet and the remaining 650 in another sheet.
Can you tell me more about the reason for splitting the records? That creates a complication, but I don't understand what needs to happen with the two groupings. How is the split determined?
I don't understand the purpose of helper cells and cell W:X how can I add all 950x30 candidates where the name might be the same in many locations? honestly, it looks great but It's very difficult for me to understand.
The helper cells in Z:AA simply provide a count of the number of candidates and the number of NA# items. I believe all of the candidates are to be shown for each NA#...is that correct? If so, then if you have 950 NA# items and 30 candidates, the entire list would require 950*30=28500 rows.
1 if you can guide me on how to add or remove the candidates without impacting the entire sheet. in your R:S I can add more candidates if I add them in W:X but in your Q I cannot add a new NA # and if I add candidates having the same name then check the below screenshot, then J, K, L, M are giving error.
The candidates and their party affiliations are input only in W:X...no where else. Any new NA# items are added in A:D...just keep adding more items to the bottom of the main table. So the helper cells in Z:AA count the number of NA# items appearing in column A and the number of candidates appears in column W...and based on those two counts, formulas in columns Q,R,S automatically create the voting tabulation table. You do not enter anything in the Q:S columns because the formulas will automatically repeat the list of candidates and party names shown in W:X...and this is done for every NA# shown in column A. So if you learn that there will be 20 candidates, you list those 20 candidates in W:X. You would also fill out the main table to show all of the NA# items (columns A:D). Then select the bottom row of the voting tabulation table, say cells Q50:U50 and drag those formulas down until they produce blanks. That will automatically create the combinations of NA#s and candidate groupings.
i have another idea, may be this could help us. the value in row A & D are unique. can we use it to solve thge condition check issue
If I understand your point, this is what I've done in column Q of the voting tabulation table. The unique NA# is used to "tag" each grouping of candidate/party names. And column Q is then used in the J:M formulas to ensure that we are only considering votes for each NA# shown (under column A) of the main table.

About those errors:
Some adjustment in the J:M formulas are needed. The #NUM! errors are caused by having no rows in the voting tabulation table that correspond to the NA#. If the formulas in Q:U are pulled down until blanks are produced in those cells, then the voting tabulation table has reached its maximum length and the #NUM! errors should go away. However, there is still an issue: if votes are not entered in the voting tabulation table, the formulas in J:M will report the winner and runner up as the first candidate for each NA# (where no votes are recorded for that NA#). This issue can be fixed, but the solution for it depends on what you want. For example, do you want the J:M columns to display the 1st and 2nd place vote winners as the votes are entered, or do you want to wait until all votes have been tabulated for that NA#. I would probably opt for the 2nd to avoid misunderstandings about declaring a winner and runner up before votes have been entered for each of the candidates.

In terms of usability, I would probably move the voting tabulation table to a separate sheet and use autofilters on the columns so that you could quickly isolate the candidate groupings for any given NA# and then enter the actual votes (unless this is somehow to be done automatically).
 
Upvote 0
Can you tell me more about the reason for splitting the records? That creates a complication, but I don't understand what needs to happen with the two groupings. How is the split determined?
i have multiple records but all are unique.
1- NA-001 to NA-280 (i can write in any format like NA001 or NA0001 NA-#0001 anything as long as it's having "NA & 1") these record will go up to 280 but still possibilities are then might be less but not more than 280
2- PP-001 to PP-500 (same scenario here like NA - write in any format, number can be increased or decreased)
3- PS-001 to PS-200 (same scenario like PP)
4- PB-001 to PB-100) (same scenario like PP)
5- KP-001 to KP-150) (same scenario like PP)

but, whatever is all NA, PP, PS, PB, KP are unique
The candidates and their party affiliations are input only in W:X.
the more i add in W:X it's keep on increasing the Q with same NA


1663673220342.png
 
Upvote 0
i tried my existing sheet and everything is working fine even with merged cell or without merging the cell.
only issue is the condition check is not working to highlight the winner name and party as well as the runner-up name and party

if for some reason, by using the unique values, (as mentioned above NA PS PB KP PP) we can update the formula in condition check then this problem can be resolved and i will start working on dashboard

Thank you once again @KRice.

1663674585208.png
 
Upvote 0

Forum statistics

Threads
1,224,825
Messages
6,181,190
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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