Saturday 15 June 2013

excel - Change the SetSourceData range when chart is created -



excel - Change the SetSourceData range when chart is created -

i have vb coding hides rows above , below required cell values used source info simple line chart.

how can select remaining (unhidden) cell range setsourcedata range ?

i can select range next ...

range("d6").offset(1, 0).select range(selection, selection.end(xldown)).select

... range begins in cell beneath cell c6.

when seek utilize setsourcedata range ...

activesheet.shapes.addchart.select activechart.setsourcedata source:=range("d6").offset(1, 0).select.range(selection, selection.end(xldown)).select activechart.charttype = xlline

... next error:

run-time error '438': object doesn't back upwards property method

any ideas ?

thanks

actually, next code selects info need little better...

range("d7", cells(rows.count, "d").end(xlup)).specialcells(xlcelltypevisible).select

... but, how utilize info source chart ?

sorry, after creating more effective select code...

range("d7", cells(rows.count, "d").end(xlup)).specialcells(xlcelltypevisible).select

...i realised had do, utilize code chart info source, remove '.select' code !!!

activesheet.shapes.addchart.select activechart.setsourcedata source:=range("d8", cells(rows.count, "d").end(xlup)).specialcells(xlcelltypevisible) activechart.charttype = xlline

runs ok now.

excel vba

No comments:

Post a Comment