excel vba - where will I put the codes when button is clicked? -
i've created macro create button when sheet activated. called using codes below: everytime go different worksheet again sheet containing button macro job. want macro work when clicked button
private sub worksheet_activate() call sortdata end sub here's code macro i've created:
sub sortdata() ' ' ' ' activesheet.buttons.add(689.25, 59.25, 133.5, 30).select selection.onaction = "sortdata" selection.characters.text = "sort data" selection.characters(start:=1, length:=28).font .name = "times new roman" .fontstyle = "bold" .size = 12 end range("a1").select end sub now problem put codes shown below when button click? or how can make button worked?? tried put codes in same sheet called macro not working.
sub sortdata_click() 'did call button right? not working when 'codes here end sub
in vba editor, click insert new module (or can put in same module sortdata is) write code new module:
sub procedurename() 'procedure name same named in selection.onaction = "sortdata" 'codes here end sub what done making sortdata() call because have set selection.onaction = "sortdata" ->>> change name whatever procedure name want perform
Comments
Post a Comment