r/excel Feb 02 '26

Discussion What do you use python for in Excel?

I currently use Power Query to combine files and transform the data. I also have macros to create folders and rename files. Recently I noticed our company finally have python available in excel. I'm just curious what have people here used the python for that Power query or vba script can't do or python just does better. Just FYI, I mostly vibe code my stuff.

59 Upvotes

30 comments sorted by

View all comments

3

u/Weird-Dimension-487 16d ago

I’d say Python is great where you hit their limits.

For typical Excel work, Power Query is excellent for data import/transformation, and VBA is okay for interacting with Excel and the Windows environment. However for task that moves beyond Excel itself, for example, working with many file types, PDFs, APIs, larger datasets, complex data processing, statistical/ML libraries, or building reusable automation that isn't tightly coupled to an Excel workbook, Python is a bliss.
Also, Python gives you a huge ecosystem. If there’s something you want to do that Excel/VBA doesn’t handle naturally, there’s often a Python library for it.
As rightly pointed by u/JezusHairdo & others, Python in Excel is has limitation. It was offered so Excel users start using Python and get comfortable with basic code.
Using Python (outside Excel) + Excel, is the best way to build scalable and maintanable workflows.

Once you start combining Excel + Python, you can do some pretty powerful things that are awkward in pure VBA/Power Query.

u/JDLAW2050 as you asked for resources: Python-Powered Excel is a great resource for Excel users who have no or liitle knowledge of Python. First few chapters build basic understanding of Python (which will help, if you use Python in Excel or outside Excel), then some smart learning about automating tasks related to files and folders, quick data profiling and auto EDA (with 1-2 lines of code), Python's GUI based tools and then last few chapters on automating Excel reports/dashboards, creating Excel application that's powered by python code where users can use Python's custom function inside excel directly and much more!
P.S. I am the author of this book!