Excel VBA: How to run two codes with the same button -


i new vba , need help. want run following separate codes same button (one code copies information worksheet another, other code adds checkboxes according last copied cell data):

sub copyinfo() dim integer dim lastrow integer dim search string dim column integer  sheets("audit").activate sheets("audit").range("a1").select 'sets autofilter sort out yes rows. selection.autofilter 'change field:=5 number of column y/n.  sheets("audit").range("$a$1:$g$2000").autofilter field:=5,   criteria1:="yes"  'finds last row  lastrow = sheets("audit").cells(sheets("audit").rows.count, "a").end(xlup).row  = 1 'change 3 number of columns got in sheet2  while <= 3  search = sheets("form").cells(1, i).value  sheets("audit").activate  'update range cover columns in sheet1.  if iserror(application.match(search, sheets("audit").range("a1:g1"), 0))     'nothing  else     column = application.match(search, sheets("audit").range("a1:g1"), 0)     sheets("audit").cells(2, column).resize(lastrow, 1).select     selection.copy     sheets("form").activate     sheets("form").cells(2, i).select     activesheet.paste  end if  = + 1 loop end sub 

and

sub checkbox()  dim torow long  dim lastrow long  dim myleft double  dim mytop double  dim myheight double  dim mywidth double '--------------------------  lastrow = range("a65536").end(xlup).row  torow = 2 lastrow      if not isempty(cells(torow, "a"))         '-         myleft = cells(torow, "c").left         mytop = cells(torow, "c").top         myheight = cells(torow, "c").height         mywidth = myheight = cells(torow, "c").width         '-         activesheet.checkboxes.add(myleft, mytop, mywidth, myheight).select          selection             .caption = "yes"             .value = xloff             .linkedcell = "e" & torow             .display3dshading = false          end      end if      next      end sub 

thank help. appreciate it.

you need call 2 procedures (sub) third one:

sub copysheet_and_checkbox() '<-- run   copysheet '<-- call first   checkbox '<-- , second same call end sub` 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -