Combine Excel & Python | Execute a Python Script from Excel using xlwings | Works on Windows & macOS

  Рет қаралды 33,767

Coding Is Fun

Coding Is Fun

Күн бұрын

Пікірлер: 65
@CodingIsFun
@CodingIsFun 3 жыл бұрын
*I will be here in the comments section. For any issues, please provide your exact error message, and I will try to help.*
@CodingIsFun
@CodingIsFun 2 жыл бұрын
@@SBHATY0U When do you get the error? When selecting the .bas file and importing it? What is the entire error message? Have you tried to run a quickstart project as shown in the video?
@CodingIsFun
@CodingIsFun 2 жыл бұрын
@@SBHATY0U Ok, but why would you like to replace the .bas file if it is working? As mentioned in the video, when creating a new project, you could include the xlwings .bas file to execute a Python file from Excel when mentioned in the video.
@sigge5395
@sigge5395 Жыл бұрын
Absolutely loved this, answered most of my questions. Thanks!!
@CodingIsFun
@CodingIsFun Жыл бұрын
Happy to hear that it was useful; thank you for taking the time to leave a comment and for watching the video! :)
@IgnacioAguilarToledo
@IgnacioAguilarToledo 9 ай бұрын
Very good explanation! Thanks
@CodingIsFun
@CodingIsFun 9 ай бұрын
Thanks for the positive feedback! Appreciate you taking the time to leave a comment. Cheers, Sven ✌️
@automateboringstuffwithraj
@automateboringstuffwithraj 4 ай бұрын
Can we use custom python UDFs in all excel files like xlsx, and unsaved excel files as well?
@GeoteknikIndonesia
@GeoteknikIndonesia Жыл бұрын
Amazing man. Can I ask u a question. So you show at minutes 9:05 on how to run the script from a folder "script". you define the python path as %%userprofile\dektop\scripts . But if you have to move the whole directory somewhere else, the scripts will not be working right? since the python path is fixed. Is there any way to define the python script relative to the "script" folder but without rechange/readjust the pyhton path again once we move the directory ?
@CodingIsFun
@CodingIsFun Жыл бұрын
Thanks for watching. You could use the Standalone option, as shown at 3:40 min and then keep the path flexible using VBA. Happy Coding!
@ojschoolz
@ojschoolz 2 жыл бұрын
Hello, I'm trying to follow along with your video but i am getting the error "'xlwings' is not recognized as an internal or external command, operable program or batch file." when trying to quickstart
@CodingIsFun
@CodingIsFun 2 жыл бұрын
Hi Ojschoolz. Have you installed xlwings by running 'pip install xlwings --upgrade'?
@me_3890
@me_3890 2 жыл бұрын
Hi, thanks for your helpful videos! The part starting at 12:07 seems to be the one relevant for me at the moment but I’m working with Jupyter Notebooks. I followed your instructions but Excel “Could not find interpreter!“ - can you help?
@CodingIsFun
@CodingIsFun 2 жыл бұрын
You might want to check if you have specified a Python interpreter path in your xlwings config file. Have a look at 7:24 min.
@elinversordepastos3204
@elinversordepastos3204 2 жыл бұрын
This content is just EXCELLENT. Thank you very much!
@CodingIsFun
@CodingIsFun 2 жыл бұрын
Glad you enjoyed the content. Thanks for watching the video and taking the time to leave a comment! :)
@praveenurugonda8023
@praveenurugonda8023 3 жыл бұрын
Hi sir. Your videos are amazing sir
@CodingIsFun
@CodingIsFun 3 жыл бұрын
Thank you Praveen Urugonda, I'm happy to hear that you've been finding the videos useful. Thanks for taking the time to leave a comment and for watching!
@calichito94
@calichito94 Жыл бұрын
I just have a question: I have a table in a excel sheet, How i could insert a new row to put data in that new row inserted? Thanks a lot
@CodingIsFun
@CodingIsFun Жыл бұрын
Thanks so much for watching the video and leaving a comment! Your request is definitely noted. However, I get a ton of requests for custom solutions and, as much as I'd love to help everyone out, I just don't have the time in my schedule to develop and test all of them. I hope you can understand. Happy Coding!
@DewanshiRamani
@DewanshiRamani 6 ай бұрын
Hello, how to use xlwings server in wsl system step by step instraction
@CodingIsFun
@CodingIsFun 6 ай бұрын
Thank you very much for watching the video and your comment. Your requirements are well noted. Yet, I receive many requests for creating individual solutions. As much as I want to help, I simply do not find the time in my daily schedule to develop & test all the different requests. I hope you can understand. Thank you! Cheers, Sven ✌️
@mando2391
@mando2391 3 жыл бұрын
Great video, any suggestions on how to make it so another user doesn't need python to run it on excel?
@CodingIsFun
@CodingIsFun 3 жыл бұрын
Thanks for watching. You could transform your Python script into a standalone executable file. Here is one example from 'Python simplified': kzbin.info/www/bejne/j2Grf2yqmbGogNE I hope this helps!
@oscarreyesjuarez8050
@oscarreyesjuarez8050 Ай бұрын
what is the python editor you use
@CodingIsFun
@CodingIsFun Ай бұрын
I used Atom in that tutorial. -Sven ✌️
@JITISH1
@JITISH1 2 жыл бұрын
Hi, thank you for the great tutorial. When I click the Run Main button, why does xlwings close my excel file and delete it from the folder as well?
@CodingIsFun
@CodingIsFun 2 жыл бұрын
Thanks for watching and for your question. Hard to tell from a distance why you are facing an error. Sorry that I cannot help.
@saurabhchougule9483
@saurabhchougule9483 9 ай бұрын
Could you please help. Df = sheet.range('A1').expand().options(pd.Dataframe, index=False).value This is not taking in the entire data from excel if the first column has blank values. Any workaround to get whole data ?
@CodingIsFun
@CodingIsFun 9 ай бұрын
Thanks for watching. You could try to use the "used_range" property on the Sheet object: docs.xlwings.org/en/stable/api/sheet.html#xlwings.Sheet.used_range Happy Coding! Cheers, Sven ✌️
@saurabhchougule9483
@saurabhchougule9483 9 ай бұрын
@@CodingIsFunThanks for replying. So used_range also did not work for me. I used current_region and it worked just right!
@theDavidJVarela
@theDavidJVarela Жыл бұрын
I am getting the following error while using macOS and OneDrive: Error Traceback (most recent call last): File "", line 1, in TypeError: 'module' object is not callable. I tried the troubleshooting section of the xlwings page, but it is not obvious to me how to execute some of the troubleshooting sections of the page. I haven't figured out how to Add the directory of your Python source file to the PYTHONPATH-again, either via Ribbon or xlwings.conf sheet. Can someone please help me understand how to address this?
@theDavidJVarela
@theDavidJVarela Жыл бұрын
The error seems to be associated with the "-" in "OneDrive-Personal"
@praveenurugonda8023
@praveenurugonda8023 3 жыл бұрын
I have doubt . I created python file in anaconda environment. I can not able to run that code by giving in macro paths only. Can you guide how to run anaconda created python file in macro by giving their paths
@CodingIsFun
@CodingIsFun 3 жыл бұрын
Do you get any error messages? Is it working when you leave the python script in the same directory as the workbook?
@praveenurugonda8023
@praveenurugonda8023 3 жыл бұрын
Thank you for your reply
@heheh92
@heheh92 2 жыл бұрын
after doing the quickstart I get a message bash is a directory. please help!
@CodingIsFun
@CodingIsFun 2 жыл бұрын
Is that the full error message? Can you cd to your desktop and try to run the quickstart command again?
@slickbuyers
@slickbuyers 2 жыл бұрын
"xlwings' is not recognized as an internal or external command," my issue with the addin install
@CodingIsFun
@CodingIsFun 2 жыл бұрын
Did you install the library?? pip install xlwings
@slickbuyers
@slickbuyers 2 жыл бұрын
Thank you for your response, ya it installed correctly,but the add-in is showing problem's
@CodingIsFun
@CodingIsFun 2 жыл бұрын
@@slickbuyers Ok, then you might want to check out the following site: docs.xlwings.org/en/stable/troubleshooting.html
@slickbuyers
@slickbuyers 2 жыл бұрын
@@CodingIsFun ok thank you.
@mypage9331
@mypage9331 2 жыл бұрын
Hello! Will xlwings work with the Microsoft365 version of Excel?
@CodingIsFun
@CodingIsFun 2 жыл бұрын
Yes
@confidential303
@confidential303 3 жыл бұрын
Hi, instead of stackoverflow I am heading towards here :P , I got a question, I made in excel a bot with chromedriver which was getting me crypto/stock prices so to calculate my value of my portfolio. But since last it didnt work anymore saying chrome version 95 is not supported by this chromedriver. So I tried to install the latest version..I just replaced the old with the new one..it didn't worked but somehow in the evening all of sudden it did work, but now the fun part..Malwarebytes wanted to do a routine scan ..I said yes and It found malware.heurestic ..so it was a zero day something..so I am not sure now, is it safe to use the latest version of chromedriver, are there any issues with it? I do want a clean system, dont like to get compromised.
@CodingIsFun
@CodingIsFun 3 жыл бұрын
Great question! ChromeDriver is actually open-source. I would consider it as safe to use 👍
@bosco9236
@bosco9236 2 жыл бұрын
I suppose this only woks on Excel 365.
@CodingIsFun
@CodingIsFun 2 жыл бұрын
Thanks for watching. No, it also works with other Excel versions
@bosco9236
@bosco9236 Жыл бұрын
@@CodingIsFun Good to know, I'll give it a shot. Thanks.
@lockmaboc9416
@lockmaboc9416 2 жыл бұрын
Hi ! Thanks a lot for your video ! It's great ! Maybe you can help me, I followed the same things you have done. First, i don't have any "xlwings" my ribbon, so I added one using : xlwings quickstart demo --addin --ribbon After that, every time i tried tu run the macro i got an error : Sub not define And I tried everything i knew it didn't works. Please can you help me ? In fact i already have a python script that I coded on my Windows Pc and I linked it to an excel file in order to run the code every time I push the button. I want to do the same on my Macbook and it driving me craizy cause it doesn't works Please !
@CodingIsFun
@CodingIsFun 2 жыл бұрын
Thanks for watching. How about starting with a quickstart project by running "xlwings quickstart myproject" first, and then use the generated Python file to adjust it to your needs. Happy Coding!
@lockmaboc9416
@lockmaboc9416 2 жыл бұрын
@@CodingIsFun thanks a lot for your message ! That's what i have done at least 10 times, but each time the VBA macro got a error : Sub is not define. I don't understand why cause i wrote the same code than you .... it's so annoying 😭
@CodingIsFun
@CodingIsFun 2 жыл бұрын
@@lockmaboc9416 I only have two possible fixes: 1) Ensure to activate xlwings. Open the VBA Editor, navigate to Tools -> References and tick the box for xlwings 2) Upgrade xlwings by running 'prip install xlwings --upgrade'
@lockmaboc9416
@lockmaboc9416 2 жыл бұрын
@@CodingIsFun I'm gonna try today thnajs a lot for your reply it help me a lot !! I have to do it for an important internship🤞🤞 hopefully it gonna works
Жыл бұрын
THANKSSSSSSSSSSSSSSS!!!!
@CodingIsFun
@CodingIsFun Жыл бұрын
My pleasure! Appreciate you taking the time to watch and leave a comment. 👍
@sureshgoku
@sureshgoku 3 жыл бұрын
Can there be a list validation using python
@CodingIsFun
@CodingIsFun 3 жыл бұрын
Thanks for watching the video. Yes, that is possible. See example below: import xlwings as xw #pip install xlwings wb = xw.Book('Book1.xlsx') sht = wb.sheets['Sheet1'] rng = sht.range('A1') validation_list = "Ahoy, From, Coding, Is, Fun" dv_type = xw.constants.DVType.xlValidateList dv_alertstyle = xw.constants.DVAlertStyle.xlValidAlertStop dv_operator = xw.constants.FormatConditionOperator.xlEqual rng.api.Validation.Add(dv_type, dv_alertstyle, dv_operator, validation_list)
@nicholasciacca1201
@nicholasciacca1201 Жыл бұрын
hello @codingisfun, when I try to make my code an EXE file using psgcompiler it gives me an error: 'Failed to execute script 'pyi_rth_win32comgenpy' due to unhandled exception: Module 'pythoncom' isn't in frozen sys.path' please help :)
@CodingIsFun
@CodingIsFun Жыл бұрын
Thanks for watching. Hard to tell from a distance. Sorry that I cannot help
@rajesh9sn
@rajesh9sn 2 жыл бұрын
Hi I am using vba to run a python script. However, the python script runs twice. Option Explicit Private Sub Worksheet_Calculate() Dim Ret_Val If Range("A1|).Value > 0 then Ret_Val = Shell("C:\Program Files\Python37\python.exe " & "F:\fut.py") End If End Sub In Cell A1 I have this formula COUNTIFS($J$28:$K$32,">"&$B$4)+COUNTIFS($J$18:$K$22,">"&$B$4)+COUNTIFS($J$38:$K$42,">"&$B$4) my python code import pyttsx3 engine = pyttsx3.init() engine.say(Hello How are you"') engine.runAndWait() what wrong am i doing? Thank you.
@CodingIsFun
@CodingIsFun 2 жыл бұрын
I am not sure why your code got executed twice. You might want to use the built in VBE debug tools to step into your code: www.screencast.com/t/KS9Xh4Lz Debug Video: kzbin.info/www/bejne/fXjJp4d8dpyNoqs
How to Replace VBA with Python(Step-By-Step Tutorial)
31:19
Excel Macro Mastery
Рет қаралды 270 М.
Run Python Code From Excel with VBA
14:32
NeuralNine
Рет қаралды 39 М.
When you have a very capricious child 😂😘👍
00:16
Like Asiya
Рет қаралды 18 МЛН
How to treat Acne💉
00:31
ISSEI / いっせい
Рет қаралды 108 МЛН
Create Stunning Python GUIs in 10 Minutes With Drag & Drop
11:38
Coding Is Fun
Рет қаралды 106 М.
NEW Python in Excel - PYTHON + EXCEL + ChatGPT = Easy!
10:32
MyOnlineTrainingHub
Рет қаралды 219 М.
How to Create an Excel Data Form Using Python + ChatGPT
13:57
Coding Is Fun
Рет қаралды 12 М.
Integrating Excel with Python using xlwings
20:00
Hamid Boustanifar
Рет қаралды 30 М.
How to automate excel using python and xlwings
13:38
Nodes Automations
Рет қаралды 1,9 М.
Will Python Kill Excel VBA?
12:39
Excel Macro Mastery
Рет қаралды 341 М.
"Junior developers can't think anymore..."
13:53
Travis Media
Рет қаралды 49 М.
Python in Excel wird ALLES verändern
12:41
Jakob Neubauer
Рет қаралды 50 М.
LLM makes animations with code using my voice
13:10
Bog
Рет қаралды 4,6 М.
When you have a very capricious child 😂😘👍
00:16
Like Asiya
Рет қаралды 18 МЛН