Excel VBA Grouping Command Buttons on Worksheets -


i have seen lot of information on getting several command buttons similar things, i've seen user forms.

i want have group of command buttons move data cell cell. don't want copy , paste same code each command button.

here part of want each command button:

range(commandbutton1.topleftcell.address).select selection.copy if application.worksheetfunction.istext(range("r5")) , range(commandbutton1.topleftcell.address).value <> range("r5")     range("r6").select     activesheet.paste     range(commandbutton1.topleftcell.address).select else     range("r5").select     activesheet.paste     range(commandbutton1.topleftcell.address).select end if application.cutcopymode = false 

i've tried use class modules can't seem function @ all. want able throw code class or run on command buttons in group. want different group of command buttons on same sheet execute different code.

what route should take?

when create first button , place excel sheet presented macro screen , when clicking new open macro screen , create sub button1_click() event or whatever named macro. other buttons created have events created in module.

in module can create new sub contains shared code:

sub sharedcode() end sub 

you can call shared code in each of events created buttons with:

sub button1_click()     sharedcode end sub 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -