1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【保存版】Excel VBAをPythonに変換するためのChatGPTプロンプト集

Posted at

Excel VBA → Python 変換テンプレート集(ChatGPT活用)

業務で使っていた Excel VBA マクロを Python に移行したい方へ。
ChatGPTを使って効率よく変換できるよう、「VBA → Python」のプロンプトテンプレートをGitHubにまとめました。

[VBA(変換元)]

Range("A1").Value = "Hello"
Range("A2").Value = Cells(1, 1).Value


[Python(変換先)]

from openpyxl import load_workbook

wb = load_workbook("sample.xlsx")  # Excelファイルを開く
ws = wb.active                     # アクティブなシートを選ぶ

ws["A1"] = "Hello"                 # A1セルに文字を入れる
ws["A2"] = ws["A1"].value          # A1の値をA2にコピー

wb.save("sample.xlsx")            # ファイルを保存する

🔧 こんな方におすすめ

  • VBAマクロの保守から Python化を進めたい
  • ChatGPTの使い方がまだよくわからない
  • Python初心者だけど、実務で役立てたい
  • プロンプトの書き方に悩んでいる

📚 内容構成

以下のようなVBA処理ごとに、ChatGPTへの依頼文(プロンプト)とPython変換例を掲載しています。

  • 01:セルの操作
  • 02:ループと条件分岐
  • 03:シートの追加・削除・名前変更
  • 04以降:ファイル保存、行列操作、書式設定、グラフ作成 etc(順次公開予定)

📌 GitHubリポジトリはこちら

🔗 https://github.com/mnrj-vv-w/vba-to-python-prompts

スター・改善案・PR大歓迎です!


💬 補足

すべて openpyxlベースで構成していますが、今後 pandas 版や GUI処理(Tkinter) も拡充予定です。
「こういう処理の変換もほしい!」というリクエストも大歓迎です 🙌


#Python #VBA #Excel #ChatGPT #openpyxl #業務効率化

1
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?