Use Google's Gemini AI directly in Excel! Analyze data, generate formulas, summarize text, and more - all without leaving your spreadsheet.
- Go to Google AI Studio
- Sign in with your Google account
- Click "Create API Key"
- Copy your API key
- Open your Excel workbook
- Press
Alt + F11to open the VBA Editor - Right-click on VBAProject → Import File...
- Import these files from the
srcfolder (in this order):Dictionary.clsJsonConverter.basmGemini.basmGeminiDemo.bas(optional - creates demo examples)
- In the VBA Editor, open the
mGeminimodule - Find this line near the top:
Const GEMINI_API_KEY As String = "YOUR_API_KEY"
- Replace
YOUR_API_KEYwith your actual API key
- Method 1 - Macro: Press
Alt + F8→ SelectGemini→ Click Run - Method 2 - Formula: Use
=AskGemini("Your question here")in any cell
| Select Data | Run Gemini | Type Instruction |
|---|---|---|
| Sales table | Alt+F8 → Gemini |
"Analyze trends" |
| Customer feedback | Alt+F8 → Gemini |
"Summarize sentiment" |
| Email list | Alt+F8 → Gemini |
"Extract first names" |
| (no selection) | Alt+F8 → Gemini |
"Write a VLOOKUP example" |
Edit these constants in mGemini.bas to customize behavior:
| Setting | Options | Description |
|---|---|---|
GEMINI_MODEL |
gemini-2.5-flash, gemini-2.5-flash-lite, gemini-3-pro-preview |
AI model to use |
GEMINI_INPUT_MODE |
both, selection, inputbox, auto |
How prompts are collected |
GEMINI_OUTPUT_MODE |
lines, single |
How responses are displayed |
I've developed some handy Excel add-ins that you might find useful:
- 📊 Dashboard Add-in: Easily create interactive and visually appealing dashboards.
- 🎨 Cartoon Charts Add-In: Create engaging and fun cartoon-style charts.
- 🤪 Emoji Add-in: Add a touch of fun to your spreadsheets with emojis.
- 🛠️ MyToolBelt Add-in: A versatile toolbelt for Excel, featuring:
- Creation of Pandas DataFrames and Jupyter Notebooks from Excel ranges
- ChatGPT integration for advanced data analysis
- And much more!
- 📺 YouTube: CodingIsFun
- 🌐 Website: PythonAndVBA
- 💬 Discord: Join our Community
- 💼 LinkedIn: Sven Bosau
- 📸 Instagram: Follow me
Love my content and want to show appreciation? Why not buy me a coffee to fuel my creative engine? Your support means the world to me! 😊
Got some thoughts or suggestions? Don't hesitate to reach out to me at contact@pythonandvba.com. I'd love to hear from you! 💡
