Export a worksheet range to csv using excel-vba -
i exporting excel csv macro using name file data in worksheet in cells in cells form no part of csv data, file name:
private sub commandbutton1_click() dim path string dim filename1 string dim filename2 string dim filename3 string path = "t:\richards reports\mg orders\" filename1 = range("a1") filename2 = range("o1") filename3 = range("m1") activeworkbook.saveas filename:=path & filename1 & "_" & filename2 & "_" & filename3 & ".txt", fileformat:=xlcsv end sub
however, need able limit output specific range, example cells i6 i60, struggling find way of accomplishing this, suggestions appreciated. tia duncan
here code save selected range .csv
sub saveselection2csv() dim range2save range dim filename range dim datarow range dim datarowarr() variant set filename = worksheets("arkusz1").range("a1") open thisworkbook.path & "\" & filename.value & ".csv" output #1 each datarow in selection.rows datarowarr = datarow.value datarowarr = application.transpose(application.transpose(datarowarr)) print #1, join(datarowarr, ",") next close #1 end sub
Comments
Post a Comment