vba - Make a button move with a cell in Excel -


i trying create spreadsheet in need button in each row stamp time in cell next , sort rows in order of time. problem buttons not move. e.g. button in cell b1 changes time in cell a1 , button in cell b2 changes time in cell a2 , example lets a2 has lower time a1 when sorted a1 , a2 swap data. button in b2 changes time in cell a1.

been trying figure out hours, appreciated.

based on david's comment, can try set up.

dim r range 

private sub commandbutton21_click()     r.offset(0, -1).value = time end sub 

private sub worksheet_selectionchange(byval target range)     on error goto halt     application.enableevents = false      if target.countlarge > 1 goto moveon     dim btn oleobject: set btn = me.oleobjects("commandbutton21")      if not intersect(target, me.range("b:b")) nothing         set r = target         btn             .visible = true             .left = r.left             .top = r.top             .width = r.width             .height = r.height         end     else         btn.visible = false     end if  moveon:     application.enableevents = true     exit sub halt:     msgbox err.description     resume moveon end sub 

you need create activex control commandbutton21 name.
buttons move , appear when selected in column b.
can add sort routine on commandbutton21_click event.


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -