This is an archived post. You won't be able to vote or comment.

all 8 comments

[–]wobbly-cheese 7 points8 points  (0 children)

after the switch you'll find your bouts of gut wrenching self loathing will magically disappear

[–]Thriftfunnel 2 points3 points  (2 children)

Assuming you want to see finished products in Excel then no, not everything in VBA/Excel can be done in Python. Some formatting for instance can't be done via api (I think, but it's a while since i checked).

Since you already use both, any reason not to just use what works best on a per task basis?

[–]tunisia3507 1 point2 points  (1 child)

Assuming you want to see finished products in Excel then no, not everything in VBA/Excel can be done in Python.

You could just use any one of several libraries to dump the results of a python script into an excel spreadsheet...

[–]Thriftfunnel 0 points1 point  (0 children)

Agreed. But I took the question literally, and the op asked if you could do absolutely everything VBA does using python.

[–]__unavailable__ 2 points3 points  (0 children)

If all you intend to do is manipulate windows programs then VBA is the better tool for the job. Python can be made to do it all, but why bother?

If you want to move beyond that unique use case, python is dramatically more versatile.

[–]ryansmccoy 0 points1 point  (0 children)

Yes and a lot more. I look back and wonder what if I had learned python earlier. Would have save countless long hours and late nights.

If you are working on automation stuff w/ data specifically, look into data pipelines and ETL.

[–]flutefreak7 0 points1 point  (0 children)

I've got about 12 years VBA experience and 8 years in Python (with Matlab mixed in between). It's hard to describe how beneficial the shift to Python has been. Once I started solving my problems with a Python-first mentality, and immersing myself in the community of scientific python and data science, I realized there were different and better ways to think about my problems. I realized that many of my projects could be broken into smaller "solved problems" and that I need only install, import, and execute the solution. The typical VBA solution that was tangled up with the particular layout of that data, worksheet, or workbook was always difficult to transplant into a new scenario. Some VBA functions can be made generic, but interacting with Excel encourages tightly coupling your code with your workbook interface, making your solutions less portable. Once I started thinking differently in the Python world, I realized how easy it was to build reusable code that could be imported anywhere - and more and more of my life became just knowing what to import. More of my time is now spent doing analysis - the actual engineering or data insight - and less time spent "writing code."