excel - VBA Deleting buttons with a range -


i'm trying figure out how delete buttons within range. i've seen plenty of examples on how delete buttons within sheet not range. created range variable contains every possible occurance of button (this used reinitialize form of variable size). problem range doesnt support object .shapes or .buttons.

        set totaltable = range(activecell, activecell.cells(1000, 1000))         each gen_btn in totaltable.shapes            gen_btn.delete         next 

any appreciated. also, can't use activesheet becuase there buttons want keep , becuase macro called button. hence need range. thank you.

this solution uses intersect method see whether shape in range , deletes shape if is.

sub delete_shapes_in_range()  dim btn shape dim totaltable range  set totaltable = range(activecell, activecell.cells(1000, 1000))  each btn in activesheet.shapes     if not intersect(btn_rng, totaltable) nothing btn.delete next btn  end sub 

note code not delete buttons, delete other shapes. if concern, can add if statement skip shapes. example:

if not btn.name "picture*" '<~~will skip pictures 

or

if not btn.name "*box*" '<~~will skip textboxes 

etc. assumes haven't renamed shapes since creating them.


Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -