vba - Delete charts from range -


i have 2 charts in range of cells trying delete vba. rather deleting charts, iterates through bunch of times without doing @ all. have tried far.

for each chartobjects in range(cells(i + 3, 12), cells(i + 19, 50))      chartobjects.delete next chartobjects 

you can use topleftcell property of chartobject check whether cell under top left corner of chart falls within range...

dim ochrtobj chartobject  each ochrtobj in activesheet.chartobjects      if not application.intersect(ochrtobj.topleftcell, _         range(cells(i + 3, 12), cells(i + 19, 50))) nothing             ochrtobj.delete      end if next ochrtobj 

note, though, can delete charts using single line...

activesheet.chartobjects.delete 

hope helps!


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -