简体   繁体   中英

Automated Excel document creation using VBA

The managing director at our company wants me to produce an automated monthly document that saves to a certain place on our system so that he doesn't have to manually input all of the data. I have set up so that the document can save to the correct place in the correct format but my knowledge of VBA is not great.

Tackling this from a 1 question at a time point of view I suppose my question would be is it possible to create 1 very long macro that will accomplish many different tasks over several workbooks. For example we have a report that comes from our ERP (Baan) and shoves all of the data into one cell. Is it possible to create a macro that will accomplish formatting text to columns, then copy data from a cell based on a row reference and then take said data and paste it in to a different workbook? Would it then be able to save the workbook all from just running one macro and if so how long will all of that take once the macro is executed?

Yes I believe this should be do-able, keeping in mind that the file names + location remain the same (otherwise you'll have to edit each month). Create different Subs/Functions and call them in one main macro.

The easiest way is probably to do it step by step. Record macro's and see whether that already helps you out and if not use google & stackoverflow for help! :)

it is entirely possible - but in my Opinion VBA is not well suited to the task. The editor is atrocius at best and it is easy to produce highly specific "spaghetti code". File operatione are possible, but are not nice. Error handling is 80s style with lots of goto. So if you want to build something maintainable, build an external Application using Interop or epplus (.net package for reading /writing to excel documents) or an .net addin for office.

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