excel - Mass edit multiple workbooks of the same format -


i'm new vba (as of morning), excuse ignorance. have few hundred excel workbooks, formatted same way (just different text). i'm trying both format , delete few sheets within workbooks (the same all).

i recorded macro works fine when applied individually, i'm getting runtime error when try run means of mass format:

    sub loopfiles()     dim myfilename, mypath string     dim mybook workbook     mypath = "i:\academic networks\all scorecard copies, 6.18.2015"     myfilename = dir(mypath & "*.xlsm")     until myfilename = ""         workbooks.open mypath & myfilename         set mybook = activeworkbook         application.run "workbook1.xlsm!scorecardmacro"         mybook.save         mybook.close         myfilename = dir     loop     end sub 

i keep getting runtime error (9) - subscript out of range. thoughts?

here's formatting/deleting i'm trying apply workbooks (which works fine when applied 1 workbook @ time:

sub scorecardmacro() ' ' scorecard macro '  '     sheets.add     sheets("scorecard").select range("d3:d36").select selection.copy sheets("sheet1").select range("b1").select selection.pastespecial paste:=xlall, operation:=xlnone, skipblanks:=false _     , transpose:=true sheets("scorecard").select range("a3:a36").select application.cutcopymode = false selection.copy sheets("sheet1").select range("b2").select selection.pastespecial paste:=xlall, operation:=xlnone, skipblanks:=false _     , transpose:=true sheets("scorecard").select range("f3:i36").select application.cutcopymode = false selection.copy sheets("sheet1").select range("b3").select selection.pastespecial paste:=xlvalues, operation:=xlnone, skipblanks:= _     false, transpose:=true sheets("checklist").select range("d4:d27").select application.cutcopymode = false selection.copy sheets("sheet1").select activewindow.scrollcolumn = 28 range("aj1").select selection.pastespecial paste:=xlall, operation:=xlnone, skipblanks:=false _     , transpose:=true sheets("checklist").select range("a4:a27").select application.cutcopymode = false selection.copy sheets("sheet1").select range("aj2").select selection.pastespecial paste:=xlall, operation:=xlnone, skipblanks:=false _     , transpose:=true sheets("additional information").select range("a4:b14").select application.cutcopymode = false selection.copy sheets("sheet1").select range("bh1").select selection.pastespecial paste:=xlvalues, operation:=xlnone, skipblanks:= _     false, transpose:=true sheets("program recommendations").select range("a4:d21").select application.cutcopymode = false selection.copy sheets("sheet1").select range("bs1").select selection.pastespecial paste:=xlall, operation:=xlnone, skipblanks:=false _     , transpose:=true activewindow.scrollcolumn = 1 range("a2").select application.cutcopymode = false activecell.formular1c1 = "" activecell.formular1c1 = _     "=mid(cell(""filename""),search(""["",cell(""filename""))+1,search(""]"",cell(""filename""))-search(""["",cell(""filename""))-1)" range("a2").select selection.autofill destination:=range("a2:a6"), type:=xlfilldefault range("a2:a6").select     sheets("program recommendations").select activewindow.selectedsheets.delete sheets("additional information").select activewindow.selectedsheets.delete sheets("scorecard").select activewindow.selectedsheets.delete sheets("checklist").select activewindow.selectedsheets.delete 

end sub

the error shows trying access doesn't exist.

since deleting something, better updates first, deletes in end.

if deletes in between , update, there might values/sheets missing


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -