excel - how to assign position to the inserted shapes basing on cell values -
depending on cell values a1= 234
, b1 = 435
,
these ""a1 value = x -coordinates "" , "b1 = y - coordinate "
.
these both cell values gives position inserted shape (rectangle) in excel sheet.
so when ever these values change dynamically not manually, position of respective shape ( rectangle) should change accordingly.
write macro values cell , set top
& left
properties of shape(rectangle in case).
sub moverectangle() activesheet.shapes("rectangle 1") .left = cells(1, "a").value 'x - coordinate .top = cells(1, "b").value 'y - coordinate end end sub
then attach macro event of value changed of these cell, have call macro worksheet_change
event. set macro trigger automatically when cell's values changes.
private sub worksheet_change(byval target range) if target.address = "$a$1" or target.address = "$b$1" call moverectangle end if end sub
now try changing values a1
or b1
, rectangle name rectangle 1
should change position accordingly.
if cells' values changed formulae, have call macro worksheet_calculate
event.
private sub worksheet_calculate() call moverectangle end sub
Comments
Post a Comment