Subscript out of range when Activating a Workbook in Excel VBA -
i have big .csv file 15 columns , 36k rows. copy first row of .csv file ( have names) in new workbook , after copy third column array , count numbers of '0' , '1'.
i error "subscript out of range" when trying activate "main" workbook after copying first row. why?
sub leerfichero() dim fichero variant dim lastrow long dim lastcolumn long dim bomba variant dim book workbook each book in workbooks if book.name = "resumen.xlsx" book.close savechanges:=false end if next book fichero = application.getopenfilename( _ filefilter:="excel workbooks, *.csv*", _ title:="elige un fichero: ", _ multiselect:=false) if fichero <> false lastrow = cells(rows.count, 1).end(xlup).row lastcolumn = cells(1, columns.count).end(xltoleft).column sheets("hoja1").range("1:1").copy workbooks.add activesheet.paste destination:=range("a1") workbooks("lixcompletoprueba2.csv").activate '<-- subscript out of range here sheets("hoja1").column("c2").copy range("c2").select range(selection, selection.end(xldown)).select selection.copy 'windows("resumen.xlsm").activate 'activeworkbook.activesheet.range("c2").pastespecial paste:=xlvalues activeworkbook.saveas _ filename:="c:\users\public\documents\libro excel\resumen.xlsx" end if end sub
Comments
Post a Comment