charts - VBA cell selection "application.union" with cells() -
i'm having trouble selecting parts of 2 different lines in sub. sub must create chart these lines datasource
, , number of second line argument of procedure. comptelignedebut
, comptecolonnefin
functions defined earlier, return integer. here's part causes issue, specific line causes error set x...
:
sub test(ligne integer) dim graphe chart dim x range set graphe = charts.add graphe.charttype = xlcolumnclustered set x = application.union(range(cells(ligne, 2), cells(ligne, comptecolonnefin)), range(cells(comptelignedebut, 2), cells(comptelignedebut, comptecolonnefin - 1))) graphe.setsourcedata (x)
thank help/advice
the union
looks ok , code below works fine me. think 1 of functions problem.
sub runthetest() test 3 end sub sub test(ligne integer) dim x range set x = application.union(range(cells(ligne, 2), cells(ligne, comptecolonnefin)), range(cells(comptelignedebut, 2), cells(comptelignedebut, comptecolonnefin - 1))) end sub private function comptecolonnefin() integer comptecolonnefin = 2 end function private function comptelignedebut() integer comptelignedebut = 2 end function
try splitting application.union
line smaller bits. check values functions return.
sub test(ligne integer) dim x range dim colonnefin integer dim lignedebut integer colonnefin = comptecolonnefin() lignedebut = comptelignedebut() set x = range(cells(ligne, 2), cells(ligne, colonnefin)) set x = application.union(x, range(cells(lignedebut, 2), cells(lignedebut, colonnefin - 1))) end sub
Comments
Post a Comment