Many histograms with VBA macro

user112233

New Member
Joined
Mar 25, 2014
Messages
1
I need to create 50 histograms, so I recorded a macro that creates 1 histogram. The code is this:

Code:
<code style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; white-space: inherit;">[COLOR=#00008B]Sub[/COLOR] histcreate 
 Application.Run [COLOR=#800000]"ATPVBAEN.XLAM!Histogram"[/COLOR], ActiveSheet.Range( _    [COLOR=#800000]"$A$3:$A$1601"[/COLOR]), ActiveSheet.Range([COLOR=#800000]"$BH$1"[/COLOR]), , [COLOR=#800000]False[/COLOR], [COLOR=#800000]False[/COLOR], [COLOR=#800000]True[/COLOR], _    [COLOR=#800000]True
[/COLOR][COLOR=#00008B]End[/COLOR] [COLOR=#00008B]Sub[/COLOR]</code>
I want to modify this macro, so that it creates not only this one histogram, but 50 histograms with ranges
Code:
<code style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; white-space: inherit;">[COLOR=#800000]"$B$3:$B$1601"[/COLOR]  [COLOR=#800000]"$C$3:$C$1601"[/COLOR]</code>

and so on. I think I should use a for loop, but I don't know how to loop through letters. $BH$1 is the first element of the 2 column output range, so I need it to be shifted by 2 in every step.

What I did was copy/pasted this code 50 times and rewrote the ranges manually, but I think it can be done with loops as well.

Thank you!
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

Forum statistics

Threads
1,221,310
Messages
6,159,173
Members
451,543
Latest member
cesymcox

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