VBA code to sum from above 5 cells to below 5 cells and selection middle cell from drop down box of column list

bullletExcel

New Member
Joined
Jul 12, 2021
Messages
7
Office Version
  1. 2019
Platform
  1. Windows
VBA code to sum from above 5 cells to below 5 cells and selection middle cell from drop down box of column list in excel
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Welcome to Mr. Excel.

It would help if you could use XL2BB and provide a few representative examples of your data and expected results
 
Upvote 0
test vba.xlsm
ABCDEFGHIJKLMN
1OISTRIKE PRICEOIC
2NIFTY2171514700CE#########952.85-63.915751470020210715CE75
3NIFTY2171514750CE#########00751475020210715CE0
4NIFTY2171514800CE#########904.75-7.8501480020210715CE0Here, strike price is going select in the drop down box and get trigger to specific row of OI and OIC column
5NIFTY2171514850CE#########880.05-14.11501485020210715CE75
6NIFTY2171514900CE#########002251490020210715CE75Select Strike price here
7NIFTY2171514950CE#########791.951.12251495020210715CE75
8NIFTY2171515000CE#########703.75-13.9179251500020210715CE-3075
9NIFTY2171515050CE#########632.85-18.330001505020210715CE300
10NIFTY2171515100CE#########609.9-10.783251510020210715CE-225
11NIFTY2171515150CE#########518.25-47.9526251515020210715CE-75
12NIFTY2171515200CE#########505.1-15.890001520020210715CE-1650here, sum from above 5 cells to below 5 cell of selected OI row
13NIFTY2171515250CE#########449.8-17.7513501525020210715CE-75
14NIFTY2171515300CE#########404.65-17.7277501530020210715CE5475Sum of OI
15NIFTY2171515350CE#########359.4-13.339751535020210715CE2100
16NIFTY2171515400CE#########306.3-19.8840001540020210715CE19575
17NIFTY2171515450CE#########238.05-41.05340501545020210715CE680same as OI, but sum in OIC column
18NIFTY2171515500CE#########215-21.353906751550020210715CE47100
19NIFTY2171515550CE#########173-23.32577751555020210715CE-33825Sum of OIC
20NIFTY2171515600CE#########134.5-22.91E+061560020210715CE10992
21NIFTY2171515650CE#########100-23.855130001565020210715CE51675
22NIFTY2171515700CE#########70-24.155E+061570020210715CE132750
23NIFTY2171515750CE#########47.95-21.83E+061575020210715CE826575
24NIFTY2171515800CE#########30.5-19.757E+061580020210715CE2E+06
25NIFTY2171515850CE#########18-17.44E+061585020210715CE2E+06
26NIFTY2171515900CE#########10.5-13.754E+061590020210715CE963600
27NIFTY2171515950CE#########6.2-10.151E+061595020210715CE328950
28NIFTY2171516000CE#########4.65-6.64E+061600020210715CE297300
29NIFTY2171516050CE#########3.4-4.259808501605020210715CE-4E+05
30NIFTY2171516100CE#########3-2.853E+061610020210715CE34350
31NIFTY2171516150CE#########2.6-1.99063001615020210715CE135375
32NIFTY2171516200CE#########2.5-1.53E+061620020210715CE-3E+05
33NIFTY2171516250CE#########2.2-1.254632751625020210715CE57225
34NIFTY2171516300CE#########2-1.154E+061630020210715CE1E+06
35NIFTY2171516350CE#########2.15-0.752345251635020210715CE39750
36NIFTY2171516400CE#########1.8-0.852E+061640020210715CE528075
37NIFTY2171516450CE#########1.8-0.7999751645020210715CE22275
38NIFTY2171516500CE#########1.85-0.54E+061650020210715CE-81000
39NIFTY2171516550CE#########1.9-0.3548251655020210715CE10875
40NIFTY2171516600CE#########1.75-0.455316751660020210715CE99750
41NIFTY2171516650CE#########1.75-0.4166501665020210715CE6375
42
43
Sheet1
 
Upvote 0
Unfortunately, I don't understand your explanation.
Is there a drop down in cell M6 and one in M14, etc.? Your red highlighted cells.

If so, do you want the sum of the E column from 2 to 5 (there aren't 5 rows above M6) ?

What is being summed (ranges) and where is the answer being placed and how does Excel know which column to sum (OI or OIC header)?
 
Upvote 0
Unfortunately, I don't understand your explanation.
Is there a drop down in cell M6 and one in M14, etc.? Your red highlighted cells.

If so, do you want the sum of the E column from 2 to 5 (there aren't 5 rows above M6) ?

What is being summed (ranges) and where is the answer being placed and how does Excel know which column to sum (OI or OIC header)?
Drop down to select cell from strike price column,
Once strike price cell is selected then selected cell row is activated,
In selected row, Sum--- from above 5 cell to below 5 cell of OI and OIC COLUMN
 
Upvote 0
Does the drop down provide a ROW number or what? Would you provide a very specific example, please?
 
Upvote 0
Maybe someone else understands what you're trying to describe. I don't

I don't know from your replies what cell(s) contain the drop down and what then is selected from the drop down.
If a drop down has an option to select, say, 15550 from the F column, that could be first in F18 or second in F19. ?????
Then, where does the sum above and below get placed?

Why can't you provide a specific example of where the selection is being made and then what is being summed and where the result is being place? One or two examples.
 
Upvote 0
Drop down is for selecting a cell from F column, to activate the specific row...
For eg..
Lets say, Cell F19 strike price is selected from drop down and now row 19 is activated,
From this row, at OI or E COLUMN, from above 5 cells to below 5 cells will be adding or sum together.
 
Upvote 0
If row 19 is selected, then 5 cells above that row + 5 cells below that row sum to 1,71E+07. I don't see what that is on your sample data.
 
Upvote 0

Forum statistics

Threads
1,214,375
Messages
6,119,170
Members
448,870
Latest member
max_pedreira

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