calculating stock market bonus shares

mwvirk

Active Member
Joined
Mar 2, 2011
Messages
293
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)
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Try this:
Book4
ABCD
1Apple2520
2Google3535
3Intel4545
4Facebook5555
Sheet2
Cell Formulas
RangeFormula
C1:C4C1=SUMIFS(Sheet1!F:F,Sheet1!A:A,A1,Sheet1!C:C,"B")
D1:D4D1=C1-SUMIFS(Sheet1!H:H,Sheet1!A:A,A1,Sheet1!C:C,"B")
 
Upvote 0
Try this:
Book4
ABCD
1Apple2520
2Google3535
3Intel4545
4Facebook5555
Sheet2
Cell Formulas
RangeFormula
C1:C4C1=SUMIFS(Sheet1!F:F,Sheet1!A:A,A1,Sheet1!C:C,"B")
D1:D4D1=C1-SUMIFS(Sheet1!H:H,Sheet1!A:A,A1,Sheet1!C:C,"B")
thanks, KRice
your formula is working fine on the test sheet but when I am applying it to my actual worksheet, it's getting all the shares in hand even if those are not bonus shares with flag "B"
it seems I have to check the actual sheet why your formula is not working there.
 
Upvote 0
Check the column references to determine if the formula needs to be revised to match your actual worksheet. Also confirm that the Flag column contains "B" with no extra characters around it.
 
Upvote 0
Check the column references to determine if the formula needs to be revised to match your actual worksheet. Also confirm that the Flag column contains "B" with no extra characters around it.
MWVirk PSX Portfolio.xlsx
ATAUAVAW
1Number Of Times Bonus Shares ReceivedTotal Bonus Shares ReceivedTotal Bonus Shares In InventoryNumber Of Times Dividends Received
20000
30000
40000
50000
60000
70000
80000
911,0001,0000
100001
110000
1213003000
130000
PSX Portfolio Status
Cell Formulas
RangeFormula
AT2:AT13AT2=COUNTIFS('PSX Trading'!A:A,A2,'PSX Trading'!C:C,"B")
AU2:AU13AU2=SUMIFS('PSX Trading'!F:F,'PSX Trading'!A:A,A2,'PSX Trading'!C:C,"B")
AV2:AV13AV2=SUMIFS('PSX Trading'!F:F,'PSX Trading'!A:A,A2,'PSX Trading'!C:C,"B",'PSX Trading'!AD:AD,0)
AW2:AW13AW2=IF(A2<>"",COUNTIF('RDA HBL Statement'!$B$16:$B$1200,"*"&A2&" Dividend"&"*"),0)
Named Ranges
NameRefers ToCells
'PSX Trading'!_FilterDatabase='PSX Trading'!$A$1:$BU$1201AT2:AV13
Cells with Conditional Formatting
CellConditionCell FormatStop If True
AV3:AV112Cell Value<>0textNO
AV2Cell Value<>0textNO
AU95:AU112,AU2:AU80Cell Value<>0textNO
AT95:AT112,AT2:AT80Cell Value<>0textNO
AW2:AW18,AW95:AW112,AW20:AW80Cell Value<>0textNO



above is without using your formula...
and below is after using your formula...




MWVirk PSX Portfolio.xlsx
ATAUAV
1Number Of Times Bonus Shares ReceivedTotal Bonus Shares ReceivedTotal Bonus Shares In Inventory
2000
3000
40012,500
5000
6000
7000
8000
911,00025,000
10000
11000
1213007,000
PSX Portfolio Status
Cell Formulas
RangeFormula
AT2:AT12AT2=COUNTIFS('PSX Trading'!A:A,A2,'PSX Trading'!C:C,"B")
AU2:AU12AU2=SUMIFS('PSX Trading'!F:F,'PSX Trading'!A:A,A2,'PSX Trading'!C:C,"B")
AV2:AV12AV2=C2-SUMIFS('PSX Trading'!AD:AD,'PSX Trading'!A:A,A2,'PSX Trading'!C:C,"B")
Named Ranges
NameRefers ToCells
'PSX Trading'!_FilterDatabase='PSX Trading'!$A$1:$BU$1201AT2:AV12
Cells with Conditional Formatting
CellConditionCell FormatStop If True
AV3:AV12Cell Value<>0textNO
AV2Cell Value<>0textNO
AU95:AU112,AU2:AU80Cell Value<>0textNO
AT95:AT112,AT2:AT80Cell Value<>0textNO
 
Upvote 0
i think i copied extra cells as dividend is also showing in 1st mini sheet (please ignore dividend cells)
 
Upvote 0
Your post shows columns AT, AU, and AV. I can't see your 'PSX Trading' sheet, but based on the formulas shown in the 'PSX Portfolio Status' sheet...
  1. I would expect to find your flag column (with some cells containing "B") in column C of 'PSX Trading'. Is this correct?
  2. I would expect to find the stock names in column A of 'PSX Trading'. Is this correct?
  3. I would expect to find the "Received" quantities in column F of 'PSX Trading'. Is this correct?
Then the formula shown in AU2:AU12 of 'PSX Portfolio Status'...
Excel Formula:
=SUMIFS('PSX Trading'!F:F,'PSX Trading'!A:A,A2,'PSX Trading'!C:C,"B")
...should return the total "B" bonus shares received for each stock name listed in A2 and down.

Since these are all 0, I am guessing that a column reference is not correct. Could you confirm my questions above?

Then for the bonus shares remaining, I am guessing that column AD of 'PSX Trading' shows the "Sold" bonus shares. Is this correct"
Then the bonus shares remaining in AV2:AV12 would be...
Excel Formula:
=AU2-SUMIFS('PSX Trading'!AD:AD,'PSX Trading'!A:A,A2,'PSX Trading'!C:C,"B")
...but check the column references, as there are clues in the first formula suggesting that at least one incorrect column is being referenced.
 
Upvote 0
Your post shows columns AT, AU, and AV. I can't see your 'PSX Trading' sheet, but based on the formulas shown in the 'PSX Portfolio Status' sheet...
  1. I would expect to find your flag column (with some cells containing "B") in column C of 'PSX Trading'. Is this correct?
  2. I would expect to find the stock names in column A of 'PSX Trading'. Is this correct?
  3. I would expect to find the "Received" quantities in column F of 'PSX Trading'. Is this correct?
Then the formula shown in AU2:AU12 of 'PSX Portfolio Status'...
Excel Formula:
=SUMIFS('PSX Trading'!F:F,'PSX Trading'!A:A,A2,'PSX Trading'!C:C,"B")
...should return the total "B" bonus shares received for each stock name listed in A2 and down.

Since these are all 0, I am guessing that a column reference is not correct. Could you confirm my questions above?

Then for the bonus shares remaining, I am guessing that column AD of 'PSX Trading' shows the "Sold" bonus shares. Is this correct"
Then the bonus shares remaining in AV2:AV12 would be...
Excel Formula:
=AU2-SUMIFS('PSX Trading'!AD:AD,'PSX Trading'!A:A,A2,'PSX Trading'!C:C,"B")
...but check the column references, as there are clues in the first formula suggesting that at least one incorrect column is being referenced.
amazing. unbelievable. man you have decoded the entire sheets even though I was trying to hide my privacy for not sharing the original sheets.
all your expectations are correct and the formula given at the end really worked perfectly.
superb. thanks a lot, dude.
I have 1 more sheet and I wish if you can help me with that. shall I post it here, please? thanks again.
 
Upvote 0
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,15048,2725,00043,27215.17%Candidate Name 0001Party Name AA1,0002.31%Candidate Name 0027Party Name BACandidate Name 0004Party Name AD11221122112211221122
3Candidate Name 0002Party Name AB5001.16%
4Candidate Name 0003Party Name AC20.00%
5Candidate Name 0004Party Name AD9,00020.80%
6Candidate Name 0005Party Name AE40.01%
7Candidate Name 0006Party Name AF2,7006.24%
8Candidate Name 0007Party Name AG60.01%
9Candidate Name 0008Party Name AH70.02%
10Candidate Name 0009Party Name AI2,7006.24%
11Candidate Name 0010Party Name AJ100.02%
12Candidate Name 0011Party Name AK110.03%
13Candidate Name 0012Party Name AL120.03%
14Candidate Name 0013Party Name AM130.03%
15Candidate Name 0014Party Name AN140.03%
16Candidate Name 0015Party Name AO150.03%
17Candidate Name 0016Party Name AP160.04%
18Candidate Name 0017Party Name AQ170.04%
19Candidate Name 0018Party Name AR180.04%
20Candidate Name 0019Party Name AS190.04%
21Candidate Name 0020Party Name AT200.05%
22Candidate Name 0021Party Name AU210.05%
23Candidate Name 0022Party Name AV220.05%
24Candidate Name 0023Party Name AW230.05%
25Candidate Name 0024Party Name AX240.06%
26Candidate Name 0025Party Name AY250.06%
27Candidate Name 0026Party Name AZ260.06%
28Candidate Name 0027Party Name BA27,00062.40%
29Candidate Name 0028Party Name BB280.06%
30Candidate Name 0029Party Name BC90.02%
31Candidate Name 0030Party Name BD100.02%
32NA-002Province-1Name-002Area-002Candidate Name 0001Party Name AA
33Candidate Name 0002Party Name AB
34Candidate Name 0003Party Name AC
35Candidate Name 0004Party Name AD
36Candidate Name 0005Party Name AE
37Candidate Name 0006Party Name AF
38Candidate Name 0007Party Name AG
39Candidate Name 0008Party Name AH
40Candidate Name 0009Party Name AI
41Candidate Name 0010Party Name AJ
42Candidate Name 0011Party Name AK
43Candidate Name 0012Party Name AL
44Candidate Name 0013Party Name AM
45Candidate Name 0014Party Name AN
46Candidate Name 0015Party Name AO
47Candidate Name 0016Party Name AP
48Candidate Name 0017Party Name AQ
49Candidate Name 0018Party Name AR
50Candidate Name 0019Party Name AS
51Candidate Name 0020Party Name AT
52Candidate Name 0021Party Name AU
53Candidate Name 0022Party Name AV
54Candidate Name 0023Party Name AW
55Candidate Name 0024Party Name AX
56Candidate Name 0025Party Name AY
57Candidate Name 0026Party Name AZ
58Candidate Name 0027Party Name BA
59Candidate Name 0028Party Name BB
60Candidate Name 0029Party Name BC
61Candidate Name 0030Party Name BD
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
F2F2=H2+G2
H2H2=SUM(L2:L31)
I2I2=IF(E2="","",F2/E2)
M2:M31M2=IF(L2="","",L2/$H$2)
N2N2=INDEX(J2:J31,MATCH(MAX(L2:L31),L2:L31,0))
O2O2=INDEX(K2:K31,MATCH(MAX(L2:L31),L2:L31,0))
P2P2=INDEX(J2:J31,MATCH(LARGE($L$2:$L$31,2),L2:L31,0))
Q2Q2=INDEX(K2:K31,MATCH(LARGE($L$2:$L$31,2),L2:L31,0))
Cells with Conditional Formatting
CellConditionCell FormatStop If True
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



there are 3 records in this sheet at this moment but actually, it will be more than 250 to 300 records.
I worked with the first entry and it worked fine for all the formulas and condition checks.
but when I copy the first record and apply it to the rest of the sheet, I am not getting similar results as I get in the first entry. in fact, I get errors in the first record as well once I copy the first record to the rest of the sheet.
this is the temporary sheet as I don't have the actual data. for each record, I have temporarily given 30 candidates which might be increased or decreased when I get the actual data. but I have to prepare it now. so I used the maximum expected numbers.
please check what is going wrong and why the condition checks are not working when I copy them to the below records.
thank you and waiting for your response.
 
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).
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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