VBA code needed

mjl78

New Member
Joined
May 5, 2011
Messages
3
I am focusing on two columns of data (the number of rows can vary). The first column has monetary values, and the second column has cost percents
EX.
COL N COL O
Row1 500,000 .0134
Row 2 690,000 .0150




Row "N" 6,000,000 .2500

I already sorted columns N and O by small to largerst value in Row N
I know how to calculate the last row

We want to get the col O sums as follows:
range 1: ($400K-750K)
range 2: (750K-2M)
range 3: ($2M-$5M)
range 4: (>5M)

Note: row 1 $ can be > that range 1 and perhaps other ranges as well. In this instance the value for the sums must equal "zero"

What is the best logic and vba code to obtain the required data?

Thanks very much
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
do you insist of a macro. see a spreadsheet solution here.

see your sheet . data is there in column N and O (N is formatted with commas,and O as dour decimal places.

the range1 etc are entered inc columns F,G H
in range 4 the maximum value is also entered (you can change it)
see the formula in I1 which is copied down

will this not do????? for easy reading format column I as number with four decimal places.

Excel Workbook
FGHIJKLMNO
1range1400,000750,0000.0284500,0000.0134
2range2750,0002,000,0002.378690,0000.0150
3range32,000,0005,000,0004.6881,029,0000.7970
4range45,000,00010,000,0001.5241,250,0000.6720
51,348,0000.1620
61,471,0000.1320
71,620,0000.6150
82,066,0000.7690
92,092,0000.5920
102,453,0000.1090
112,513,0000.6360
122,577,0000.3870
133,276,0000.1420
143,305,0000.8860
153,490,0000.8870
164,890,0000.2800
175,290,0000.3240
185,317,0000.0630
195,707,0000.3480
205,724,0000.4900
215,930,0000.2990
Sheet1
 
Upvote 0

Forum statistics

Threads
1,224,503
Messages
6,179,134
Members
452,890
Latest member
Nikhil Ramesh

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