r/vba • u/0x80070002 • 6d ago
Discussion Do you use Python instead of VBA?
I have not understood exactly the difference between xlite and pyXLL but I am wondering if someone uses Python to code and why?
21
Upvotes
10
u/HeavyMaterial163 5d ago
I prefer Python, but there are projects where VBA makes more sense. Data handling and transformation is easier with a longer list of better implemented data structures, I have more control of nearly everything, better OOP implementation, and a lot more freedom in GUI design. Not to mention less verbose.
13
u/Joelle_bb 6d ago edited 5d ago
I do now for 2 reasons:
I have to because of my job (my team opposes use of vba since its not common in our tech stack, and I'd be the only person who can service the mid tier and complex builds I have made)
I can do more with it than I ever could in vba, including everything I did in vba
I've ported most of my substantial macros into either python apps or .bats that can be executed if the end user has python set up
4
u/welktickler 5d ago
I have been using VBA as one of my tools at work for over ten years. I recently started learning python as it is better suited to the data stuff I do.I love and hate VBA. Its very powerful and you can do some really cool stuff. But things like having to late bind so you can use a dictionary is very poor in modern times. I am liking python but i feel like I have less control over things than VBA. That may be a good thing for work so i can just do the data bits.
Another reason I want to learn python is because of stuff like this; I recently went for a job interview and the manager rubbished VBA as just "macros and we hate macros here" He just wouldnt listen when I explained that it was OPP (not fully I know but,,) and really powerful or that it was proper coding.
3
u/justanothersnek 5d ago
Have you checked out xlwings?
3
u/JennaSys 5d ago
I started using VBA in the 90s but use Python now unless I'm needing to work with Access or MS Office automation specifically. Python just supports a richer and more flexible ecosystem.
1
u/keith-kld 4d ago
I used VBA since 1990s. Now, if I want to run the Code outside Ms Word or Ms Excel, I use Powershell 7.7. I don’t know if Python can be better than them or not.
1
u/AFRIENDlyyGuy 3d ago
I was a "main" VBA lol. Did an incredible system with it. Generated Invoices, to stock control to integrations with bank. All with pure logic and userforms.
I personally love it and always will. It was my entry door to progamming as well.
But when it comes the time to escalate, python is so much better. With AI i did basicallly
everthing in a few months and MUCH more. And that was the worst part, realizing my old best friend VBA was slipping trought my finger was like a grief to me ahhhahaha
1
u/jackofspades123 5d ago edited 5d ago
I use vba and python (usually not together).
Vba if developing stuff for the office where no one knows python and python at home for my own. Each are good in their own way.
What is it you're wanting to do?
Edit: Pyxll does RTD if that matters for your use case.
1
u/Frequent-Complaint-6 5d ago
Yes python all the way.
1
u/pdf_to_excel_nerd 5d ago
I use Python for most of it now. The big one for me is that you're not limited to the classes and methods Excel gives you, so anything outside the workbook (PDFs, CSVs, APIs, other files) is just another library away.
Also, having one common script dynamically pick up whatever files land in a folder and process them is a real pain in VBA. In Python it's a few lines with pathlib plus openpyxl or pandas.
0
u/TapNo3926 4d ago
AI writes all my code now. It prefers python unless I explicitly ask it for VBA. Python is more robust.
-3
u/Thadrea 3 5d ago
I don't use VBA any more. Anything that VBA can do can be done better, more maintainably, in Python.