Part of my VBA Code is a bottleneck, looking for a way to clean it up

soneil9

New Member
Joined
Dec 22, 2016
Messages
4
Hey everyone,

So I am by no means a VBA coder. What I have done hear is recorded macros and then manipulated the VBA code behind them. I have a particular piece of code that is acting as a bottleneck. What I'm trying to do is generate percentages from the cumulative total of a dynamic range in a column:

Code:
Sub CumulativePercent()Range("D2").Select
ActiveCell.FormulaR1C1 = "=RC[-1]/LOOKUP(2,1/(C[-1]<>""""),C[-1])"
Range("D3").Select
Range("C2").Select
Selection.End(xlDown).Select
ActiveCell.Offset(0, 1).Select
Range(Selection, Selection.End(xlUp)).Select
Selection.FillDown
End Sub

Does anyone have a better way of tackling this where it's not locking up my excel memory?

Thank you,
Sean
 
Don't see any reason for the LOOKUP in the formula, calculating % of total should be just a simple formula - value/total value.
 
Upvote 0
Marcelo,

Your code is now working beautifully, even with thousands of rows. Thank you all very much for your support!

-Sean
 
Upvote 0

Forum statistics

Threads
1,226,772
Messages
6,192,928
Members
453,767
Latest member
922aloose

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