good afternoon all,
i building excel sheet coworkers use generate csv files. need output header row , data sheet. no more 40 rows, less rows. have lot of formulas in sheet doing heavy lifting coworkers on things generating usernames/etc input data. need have them click button , csv file on other end. current issues follows.
1.) csv contains double quotes on every field, though commas should not in input data. need prevent program feeding these csv files not double quotes @ all. yes, know can open in notepad , replace remove them im trying build 1 click solution of folks using not tech savvy.
2.) macro exporting forty rows of data currently. need export rows contain data. theoretically formulas built there should no "partial" rows, full row or blank row.
3.) when generating csv file not appending filetype @ all, need specify .txt. filetype if @ possible again, program feeding these picky.
sub commandbutton1_click() dim filename string dim myfile string, rng range, cellvalue variant, integer, j integer filename = inputbox("please enter file name", "save csv", "csv_" & format(now, "dd_mm_yyyy")) myfile = application.defaultfilepath & filename set rng = range("a1:j41") open myfile output #1 = 1 rng.rows.count j = 1 rng.columns.count cellvalue = rng.cells(i, j).value if j = rng.columns.count write #1, cellvalue else write #1, cellvalue, end if next j next close #1
end sub
this code have like. unfortunately wasn't able rid of double quotes, maybe else has idea that.
sub csvexport() dim filename string dim myfile string, cellvalue variant, integer, j integer dim ws worksheet filename = "\" & inputbox("please enter file name", "save csv", "csv_" & format(now, "dd_mm_yyyy")) & ".txt" myfile = application.defaultfilepath & filename set ws = worksheets("yoursheetname") ws open myfile output #1 = 1 .usedrange.rows.count j = 1 .usedrange.columns.count cellvalue = .cells(i, j).value if j = .usedrange.columns.count write #1, cellvalue else write #1, cellvalue, end if next j next close #1 end end sub
Comments
Post a Comment