Error copying data to new Excel sheet using a Macro -


this first post here.

i trying copy data 1 sheet new sheet in same workbook after filtering in main sheet.

i have copy sheet template template sheet onto new sheet copying data before copy data.

this vba code shown in macro:

sub macro7() ' ' macro7 macro '  '     sheets("template").select     rows("1:3").select     application.cutcopymode = false     selection.copy     dim ssheetname string     sheets.add after:=sheets(sheets.count)     ssheetname = activesheet.name      activesheet.paste     sheets("sheet1").select     range("n13").select     range(selection, selection.end(xldown)).select     application.cutcopymode = false     selection.copy     sheets("ssheetname").select     range("d4").select     activesheet.paste     columns("d:d").entirecolumn.autofit     sheets("sheet1").select     range("a13").select     range(selection, selection.end(xldown)).select     application.cutcopymode = false     selection.copy     sheets("ssheetname").select     range("c4").select     activesheet.paste     sheets("sheet1").select     range("d13").select     range(selection, selection.end(xldown)).select     application.cutcopymode = false     selection.copy     sheets("ssheetname").select     range("e4").select     activesheet.paste     sheets("sheet1").select     range("b13").select     range(selection, selection.end(xldown)).select     application.cutcopymode = false     selection.copy     sheets("ssheetname").select     range("f4").select     activesheet.paste     sheets("sheet1").select     range("h13").select     range(selection, selection.end(xldown)).select     application.cutcopymode = false     selection.copy     sheets("ssheetname").select     range("g4").select     activesheet.paste     sheets("sheet1").select     range("f13").select     range(selection, selection.end(xldown)).select     application.cutcopymode = false     selection.copy     sheets("ssheetname").select     range("i4").select     activesheet.paste     range("a4").select     application.cutcopymode = false     activecell.formular1c1 = "fives cinetic corp"     columns("b:b").select     columns("a:a").columnwidth = 17.57     range("a4").select     selection.autofill destination:=range("a4:a5")     range("a4:a5").select     range("d10").select end sub 

i error: run-time error 9: subscript out of range

guess sheet numbers not able figure out is.

just incase haven't solved already, take @ code i've adapted you. when making new vba projects, play around of these methods, you'll find they're lot faster , more reliable previous version. compare them side side.

this took lot of assumption on part make backup before running test , make sure going right place.

sub macro7()      sheets.add after:=sheets(sheets.count)     newsheet = activesheet.name     sheets("template").rows("1:3").copy destination:=activesheet.range("a1")      sheets("sheet1").activate     range("n13").select     range(selection, selection.end(xldown)).select     selection.copy destination:=sheets(newsheet).range("d4")      sheets(newsheet)         columns("d:d").entirecolumn.autofit     end      range("a13").select     range(selection, selection.end(xldown)).select     selection.copy destination:=sheets(newsheet).range("c4")      range("d13").select     range(selection, selection.end(xldown)).select     selection.copy destination:=sheets(newsheet).range("e4")      range("b13").select     range(selection, selection.end(xldown)).select     selection.copy destination:=sheets(newsheet).range("f4")      range("h13").select     range(selection, selection.end(xldown)).select     selection.copy destination:=sheets(newsheet).range("g4")      range("f13").select     range(selection, selection.end(xldown)).select     selection.copy destination:=sheets(newsheet).range("i4")      sheets(newsheet).activate     range("a4").value = "fives cinetic corp"     columns("a:a").autofit     range("a4").autofill destination:=range("a4:a5")     range("d10").select end sub 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -