vba - Excel copy sheet following active sheet -


i'm wanting copy sheet using vba new sheet following sheet being copied

i'm using code , works puts copied sheet @ end of list of sheets

dim x integer  x = inputbox("enter number of times copy sheet, puts copies @ end of sheet list") numtimes = 1 x   'loop using x index number make x number copies.   activeworkbook.activesheet.copy _       after:=sheets(sheets.count)  next 

lets list of sheets - sheet (1), sheet (2), sheet (3), sheet (4) if run code on sheet (2) want new copy in between sheet (2) , sheet (3), passable?

also if cancel popup box asks number of sheet copies gets in error there way keep happening?

you use activesheet's index: after:=sheets(activesheet.index).

not sure if know vba, name implies, whatever active sheet is, index used. without knowing more of code, work specific instance asked here. if have multiple worksheets (which do), you'll instead want set variable worksheet you're working in, use in sheets() part...i.e.

sub t() dim x integer dim myworksheet worksheet  myworksheet = sheets("data sheet") x = inputbox("enter number of times copy sheet, puts copies @ end of sheet list") numtimes = 1 x   'loop using x index number make x number copies.   myworksheet.copy _       after:=sheets(myworksheet.index) next end sub 

now, uses single worksheet. you'd need add little logic loop through all, shouldn't hard find out how do. if more help, let me know.


Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -