excel - How can I make a part of a formula to vary? -


i trying make part of code change while worksheet change, not work. changing 1 worksheet other ok, changing integer not work in code. create j integer grow in 1 unit worksheet change. therefore, graph , shapes based on sheet (dados) has data in different lines provide information each worksheet.

sub relatorio() dim ws worksheet, gi integer, gf integer, j integer j = 0 each ws in activeworkbook.worksheets     ws         j = j + 1         if .name = "brasil"             = (8 * j) + 4   'the 8 amount of lines below need catch , 4 because data starts on line 4.              gi = (13 * j) + 271             gf = (13 * j) + 283             end if         if .name <> "dados"             .shapes("tri")                 .formula = "=dados!a2"                 .shaperange.textframe2.textrange.font.name = "calibri"                 .shaperange.textframe2.textrange.font.size = 9             end 

it not work following step on. please me solve problem?

        .shapes("pit")             .formula = "=dados!e(i)"             .shaperange.textframe2.textrange.font.name = "calibri"             .shaperange.textframe2.textrange.font.size = 9         end         .chartobjects("gráfico 8")             activechart.plotarea.select             activechart.fullseriescollection(1).values = "=dados!$e$(gi):$e$(gf)"             activechart.fullseriescollection(1).xvalues = "=dados!$b$(gi):$c$(gf)"             activechart.setelement (msoelementdatalabeltop)             activechart.fullseriescollection(1).datalabels.select             selection.numberformat = "#.##0,0"         end     end if next end sub 

i thinking line causing problem .formula `= "=dados!e(i)" , intended variable ? written not. know assign in previous sheet, sheet not.

perhaps try: .formula = "=dados!e(" & & ")"


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -