excel - Many histograms with VBA macro -


i recorded macro creates histogram. code this

sub histcreate    application.run "atpvbaen.xlam!histogram", activesheet.range( _     "$a$3:$a$1601"), activesheet.range("$bh$1"), , false, false, true, _     true end sub 

i want modify macro, creates not 1 histogram, 50 histograms ranges

"$b$3:$b$1601"   "$c$3:$c$1601" 

and on. think should use loop, don't know how loop through letters. thank you!

try (untested, revised per comments). uses .offset method counter/loop variable, i, inside loop.

sub histcreate dim firstrange range dim secondrange range dim numberofcolumns long  '### how many columns wide data plot histograms? numberofcolumns = 50  '### define first column of data used histogram set firstrange = activesheet.range("$a$3:$a$1601")  '### define second range (originally $bh$1) set secondrange = activesheet.range("$bh$1)  = 0 (numcolumns -1)     application.run "atpvbaen.xlam!histogram", _         firstrange.offset(0,i).address, _         secondrange.offset(0,i*2), _         , false, false, true, true next  end sub 

update comments

i think there wrong function call. examples find elsewhere show different arguments or @ least, not omit range argument. see example here.

examples given here suggest different order of arguments, first , third arguments range objects, , second argument given "" null string.

this function not well-documented, think if follow first link , try , figure out 3 range arguments need be, able update code needed.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -