Python in Excel for yfinance

OldSwimmer1650

New Member
Joined
Dec 3, 2020
Messages
44
Office Version
  1. 365
Platform
  1. Windows
Can someone help me with a good reference book for Python in Excel?
I bought a book but I can't find the simplest things like setting a cell value using Python code.
I think it has something to do with loading the correct library.

I'm trying to write x+y to cell C4 without putting the code in that cell.
I can assign values to cells using x=xl("A1") but can't figure out how to write values to cells without using code in that cell.

How/where do I import additional library's when using Python in Excel?
I'm starting small to get the hang of it.

My goal is to have stock symbols in one column then fill related stock values (price, change, volume, etc...) in the columns to the right.
I think that I'll need to load yfinance
Screenshot 2025-01-20 223541.png
Screenshot 2025-01-20 223609.png
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
I haven't found a book yet, maybe MrExcel wants to co-write one with you ;-)? Seriously: it's quite new material, so if you're getting the hang of it, it might be worth writing about it.

Some links that may help:
Excel 2024: Using Python in Excel (basics)
How to Use Python in Excel (more advanced, more complex formulas and processes)
Open-source libraries and Python in Excel - Microsoft Support (shows e.g. how to import a new library)

On your second question: I think that Python in Excel won't be able to write values in other cells other than having a table/array/spill result. So than your Python code goes in the top left cell and the results will start from there. The python won't be able to e.g. change cell A1 on another sheet, for that you'd need VBA I think.
 
Upvote 0
I haven't found a book yet, maybe MrExcel wants to co-write one with you ;-)? Seriously: it's quite new material, so if you're getting the hang of it, it might be worth writing about it.

Some links that may help:
Excel 2024: Using Python in Excel (basics)
How to Use Python in Excel (more advanced, more complex formulas and processes)
Open-source libraries and Python in Excel - Microsoft Support (shows e.g. how to import a new library)

On your second question: I think that Python in Excel won't be able to write values in other cells other than having a table/array/spill result. So than your Python code goes in the top left cell and the results will start from there. The python won't be able to e.g. change cell A1 on another sheet, for that you'd need VBA I think.
Thank you for the information.
 
Upvote 0

Forum statistics

Threads
1,225,738
Messages
6,186,734
Members
453,369
Latest member
juliewar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top