简体   繁体   中英

Modify Excel File and save as CSV using vba

I am working on populating a new application full of resident data. I have to export a list of residents for each property. Unfortunatly the new application has to have the residents imported 1 property at a time. This means im stuck loading 200+ properties by exporting an excel file, slightly modifing the data and then importing into the new application.

For each property that is exported I must remove a '-' from the first column and i have to remove all of the ',' throughout the entire document. I then change the formating on a date column to 'mm/dd/yyyy'. Then the document is saved as a CSV and can be imported.

I would like to write a script that can perform the updates to the excel file and save it to a csv. Please advise if this is worth my time. This is a one time load so it might be better to just power through.

Thank You

Possibly a little prematurely, as I'm not certain this is what you want to achieve, but you could try this (save first):

Sub replaceStuff()

    ActiveSheet.Range("A:A").Replace "-", ""
    ActiveSheet.Cells.Replace ",", ""
    ThisWorkbook.SaveAs "doc", xlCSVWindows

End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM