Hi all, This is a little off-topic, but it is on the general topic of getting data in R. I'm looking for a excel macro / vba script that will export all spreadsheets in a directory (with one file per tab) into csv. Does anyone have anything like this? Thanks, Hadley
[OT] VBA to save excel as csv
3 messages · Hadley Wickham, Henrique Dallazuanna, Eik Vettorazzi
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20090615/4344deab/attachment-0001.pl>
Hi Hadley,
in VBA you can do sth. like
Sub save_all_csv()
oldName = ThisWorkbook.FullName
curpath = ThisWorkbook.Path
For Each ws In ActiveWorkbook.Worksheets
ws.SaveAs Filename:=curpath & "\" & ws.Name & ".csv",
FileFormat:=xlCSV, CreateBackup:=False
Next
'bring old file back
Workbooks.Open Filename:=oldName
ThisWorkbook.Close savechanges:=False
End Sub
My Excel (2000) has no SaveCopyAs - method for other file formats than
xls, so I'm using .SaveAs, which saves the file and replaces the current
worksheet with the saved one - thats why the code for bringing back the
starting file
hth.
Hadley Wickham schrieb:
Hi all, This is a little off-topic, but it is on the general topic of getting data in R. I'm looking for a excel macro / vba script that will export all spreadsheets in a directory (with one file per tab) into csv. Does anyone have anything like this? Thanks, Hadley
Eik Vettorazzi Institut f?r Medizinische Biometrie und Epidemiologie Universit?tsklinikum Hamburg-Eppendorf Martinistr. 52 20246 Hamburg T ++49/40/7410-58243 F ++49/40/7410-57790