vba - How to get last cell index in Excel -


i'm creating line chart data

sub finaltest()     activesheet.shapes.addchart2(332, xllinemarkers).select     activechart.setsourcedata source:=range("a2:d352")     activechart.fullseriescollection(1).name = "=sheet1!$c$1"     activechart.fullseriescollection(2).name = "=sheet1!$d$1"     activechart.hastitle = true     activechart.charttitle.text = "test"     activechart.setelement (msoelementlegendright)     activechart.parent          .height = 325 ' resize          .width = 3000  ' resize          .top = 100    ' reposition          .left = 350   ' reposition     end         end sub 

my last cell d352 , index varies different sheets. how can change code works dynamically taking last used cell index?

supposing last index given last not empty cell in column a

change:

activechart.setsourcedata source:=range("a2:d352") 

to:

activechart.setsourcedata source:=range("a2:d" & cells(rows.count, 1).end(xlup).row) 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -