i trying sort range in excel within code in vb.net (visual studio).the error message saying: unhandled exception of type 'system.runtime.interopservices.comexception' occurred in microsoft.visualbasic.dll additional information: reference not valid.
the code trying execute is:
with objexcelwb.sheets("extraction_breaches") .range("a2:aw138").sort( _ key1:= .range("a2:a138"), _ order1:=excel.xlsortorder.xlascending, _ type:=excel.xlsorton.xlsortonvalues, _ dataoption1:=excel.xlsortdataoption.xlsortnormal, _ header:=excel.xlyesnoguess.xlno, _ matchcase:=false, _ orientation:=excel.xlsortorientation.xlsortcolumns, _ sortmethod:=excel.xlsortmethod.xlpinyin) end
i trying
activeworkbook.worksheets("sheet1").sort.sortfields.clear activeworkbook.worksheets("sheet1").sort.sortfields.add key:=range("d1"), _ sorton:=0, order:=2, dataoption:=0 activeworkbook.worksheets("sheet1").sort .setrange range("a2:s8") .header = 2 .matchcase = false .orientation = 1 .sortmethod = 1 .apply end
Comments
Post a Comment