How to Request More VBA Code from an AI Assistant in Spreadsheets
Question details
The user wants to know how to prompt an AI assistant to provide an extended VBA code example, specifically a script that lists all formula cells within a worksheet.

- Product
- Spreadsheet
- Device & OS
- not provided
- Scenario
- Interacting with an AI chatbot or assistant to generate a specific, advanced VBA macro for spreadsheet automation.
- Observed behavior
- The user needs the correct method to request expanded code, as no special buttons are provided in the AI interface, and a functioning VBA script to extract formula addresses.
Ensure your workbook is saved as a Macro-Enabled Workbook (.xlsm) and identify exactly what task you want the AI to automate before writing your prompt.
Prompt the AI Assistant with Plain Language
AI assistants do not require special buttons or commands; you simply need to ask clearly for the expanded VBA code using natural language.
Modern AI assistants rely on conversational context. If the AI offers to provide an expanded version of a script, you can trigger the generation simply by confirming the request in plain English.
Navigate to the AI assistant interface you are using alongside your spreadsheet.
Enter a clear follow-up prompt such as, "Yes, please provide the version that lists the addresses in a worksheet."
Once the AI generates the VBA script, locate the code block in the chat response and click the 'Copy' icon or highlight and press CTRL+C.

Implement the Generated VBA Code
Once the AI provides the code to list formula cells, you must insert it into the VBA editor to execute the task.
Leverage WPS Office for Smarter Spreadsheet Automation
WPS Office integrates powerful AI capabilities directly into WPS Spreadsheet, allowing you to generate complex formulas, analyze data, and streamline repetitive tasks without needing extensive programming knowledge.
- 1. Install WPS Office: Download and install WPS Office, then open a new or existing workbook in WPS Spreadsheet.
- 2. Access Developer Tools: Enable the Developer tab to access the built-in VBA editor where you can paste your AI-generated macro scripts.
- 3. Utilize WPS AI: Click the WPS AI tab on the ribbon to launch the assistant for instant formula generation and data insights.

Frequently Asked Questions
Can the AI assistant write a VBA macro entirely from scratch?
Yes. You do not need to start with existing code. Simply describe your exact requirements to the AI, such as "Write a VBA macro that highlights all cells containing formulas in yellow," and it will generate the complete script.
Do I need to know VBA programming to use AI-generated code?
You do not need to be an expert programmer, but having a basic understanding of how to open the VBA editor (ALT + F11), insert a module, and run the macro is necessary to apply the AI's output to your spreadsheet.
Why is my AI-generated VBA code giving a runtime error?
AI-generated code might reference worksheet names or cell ranges that do not exist in your specific file. Review the code to ensure that variables like 'ActiveSheet' or hardcoded sheet names match your workbook's actual structure.
How can I make the AI refine the VBA code it just provided?
If the code isn't exactly what you need, reply to the AI with specific adjustments. For example, say "Update this code to only check column C for formulas" and the AI will rewrite the script accordingly.




