Let's start Python from Excel. I don't use VBA.

This is my first post.

Would you like to store data in Excel and execute Python? Do you want to start Python from Excel when you repeat data change ⇔ execution?

There is a way to use VBA when I search the net, but I don't like it so I tried this method.

Target

Those who have all of the following ・ I want to analyze the data stored in Excel with Python. ・ I want to use Excel as the front end ・ I don't want to use VBA ・ I am using Windows

Overview

Start bat using the Excel hyperlink. If you write a statement to start Python in the bat file, Python will work just by pressing the link from Excel.

0. Initial state

Suppose you have an Excel file and a Python file you want to run, as shown below. image.png

1. Create bat file

Create a bat file as shown below. The save location is the same as the above file. The first line is cd to "% ~ dp0". "% ~ Dp0" is a value that indicates the path where this bat file was saved. The second line is the Python startup statement. image.png

2. Create a hyperlink in Excel

Right-click on the cell you like in Excel and select "Link" to select the bat file you created earlier.

3. Run

If you press this hyperlink, bat will open automatically and Python will start automatically. In Python, you should set pandas to read Excel data.

the end

It was a trick, but I was able to achieve my goal without using VBA. Please use it if you like.

Recommended Posts

Let's start Python from Excel. I don't use VBA.
I want to use jar from python
I want to use ceres solver from python
Let's use different versions of SQLite3 from Python3!
Use thingsspeak from python
Use fluentd from python
Use MySQL from Python
Run python from excel
Use MySQL from Python
Use BigQuery from python.
Use mecab-ipadic-neologd from python
Run Python from Excel VBA with xlwings & tutorial supplement
I wanted to use the Python library from MATLAB
Let's use def in python
Let's use python janome easily
Let's run Excel with Python
Start / stop GCE from python
Use e-Stat API from Python
I want to start a lot of processes from python
Introduction to Python for VBA users-Calling Python from Excel with xlwings-
Let's use Watson from Python! --How to use Developer Cloud Python SDK
Use Stanford Core NLP from Python
Read and use Python files from Python
Forcibly use Google Translate from python
Let's play with Excel with Python [Beginner]
[Introduction to Python] Let's use pandas
Use kabu Station® API from Python
Use Azure Blob Storage from Python
Use the Flickr API from Python
[Introduction to Python] Let's use pandas
Use fastText trained model from Python
[Introduction to Python] Let's use pandas
Use Google Analytics API from Python
Use Python from Java with Jython. I was also addicted to it.
Use PostgreSQL data type (jsonb) from Python
Use machine learning APIs A3RT from Python
[Introduction to Python] Let's use foreach with Python
Use Google Cloud Vision API from Python
I tried using UnityCloudBuild API from Python
What I got from Python Boot Camp
Use Django from a local Python script
Use C ++ functions from python with pybind11
[Note] Execute Python code from Excel (xlwings)
[Python] Start diary from today Atcorder ABC058-B
python I don't know how to get the printer name that I usually use.
Start python
Edit Excel from Python to create a PivotTable
I want to use MATLAB feval with python
Firebase: Use Cloud Firestore and Cloud Storage from Python
Create a C array from a Python> Excel sheet
Study from Python Hour7: How to use classes
Import Excel file from Python (register to DB)
I want to email from Gmail using Python.
[Python] I want to manage 7DaysToDie from Discord! 1/3
I tried Python! ] I graduated today from "What is Python! Python!"!
[Bash] Use here-documents to get python power from bash
I compared "python dictionary type" and "excel function"
I tried debugging from Python via System Console
Read Excel name / cell range with Python VBA
I don't want to use -inf with np.log
I can't click the Selenium checkbox Python VBA