excel - Determining values when looping through multiple ranges in VBA -
i working on macro set chart max , mins based on dynamic data set. when user chooses group, chart updates, , macro runs update chart max , min values appropriate scale.
i hoping can me try use variables 3 ranges to:
- choose chart based on cell value in range
- set min based on cell value in range
- set max based on cell value in range
at point able pull out chart name, having trouble getting value min , max range.
any appreciated!
sub rescale() activesheet.calculate dim chrtnmrng range dim chrtminrng range dim chrtmaxrng range dim cell range set chrtnmrng = sheets("data").range("o5:o20") set chrtminrng = sheets("data").range("z5:z20") set chrtmaxrng = sheets("data").range("aa5:aa20") each cell in chrtnmrng sheets("dashboard").chartobjects(cell.value).chart.axes(xlvalue) .minimumscale = chrtminrng.value .maximumscale = chrtmaxrng.value end next cell end sub
do this:
sub rescale() dim chrtnmrng range, cell range activesheet.calculate set chrtnmrng = sheets("data").range("o5:o20") each cell in chrtnmrng sheets("dashboard").chartobjects(cell.value).chart.axes(xlvalue) .minimumscale = range("z" & cell.row) .maximumscale = range("aa" & cell.row) end next cell end sub
the key here ranges minimum , maximum values (z
, aa
) line precisely column o
can use row
reference corresponding values need.
Comments
Post a Comment