Forum Discussion
How do you respond to...
Hello my Excellers,
I wish you all a happy new year full of great things.
I have a question and I am not sure if this is a purely an Excel question or something else but maybe I start here and see how it goes:
As you all may have noticed the AI craze is blooming like crazy. If you want to sell lettuce slap AI on its label and step back.
I use Bing to search for VBA examples. For example I typed "excel vba code to find cells with formulas" and I get AI to find or "compose" a decent example that with minimal editing will work perfectly.
But then at the end of the code and its explanation I sometimes find these kind of questions: "If you want to list the addresses of formula cells instead of highlighting them, I can give you a version that outputs them in the Immediate Window or a new sheet.
Do you want me to provide that listing version as well?"
How do you say YES I want that code that would list the addresses in a sheet?
I see buttons like "Undo" rounded Left Arrow, or "Redo" rounded Right arrow, and a "Copy, "Export", and then "Tweak Content", "Rewrite" button, A "Testing Tools" dropdown with options like "Generate test data" and "Integrate test cases", and another dropdown called "More Actions" with options like "Perform code review", "Explain the code", "Add error handling", and "Make code compliable" and the last dropdown "Work Report" with its own options.
But I do not see anything that would allow me to say YES I want that code that would list the addresses in a sheet?
Thanks for any insight...
GiGi
1 Reply
- Olufemi7Iron Contributor
Hello GeorgieAnne,
You can simply type "Yes, please give me the version that lists the addresses in a sheet" into the AI chat — there isn’t a hidden button for this. The AI responds to plain language, not the interface buttons.
Microsoft Documentation
Range.HasFormula property: https://learn.microsoft.com/en-us/office/vba/api/excel.range.hasformula — Returns True if all cells in the range contain formulas, False if none do.
Range.Find method: https://learn.microsoft.com/en-us/office/vba/api/excel.range.find (learn.microsoft.com in Bing) — Useful if you want to search for specific formulas or values.
To "say yes" to the AI, just type your request clearly in the chat. And if you want to explore further, Microsoft’s official VBA documentation on Range.HasFormula and Range.Find gives you the building blocks to customize how formulas are detected and listed.
Example VBA code to list formula cells in a new worksheet:
Sub ListFormulaCells()
Dim ws As Worksheet
Dim cell As Range
Dim outputWs As Worksheet
Dim rowNum As Long
Set ws = ActiveSheet
Set outputWs = Worksheets.Add
On Error Resume Next
outputWs.Name = "FormulaCells"
On Error GoTo 0
rowNum = 1
outputWs.Cells(rowNum, 1).Value = "Cell Address"
outputWs.Cells(rowNum, 2).Value = "Formula"
For Each cell In ws.UsedRange
If cell.HasFormula Then
rowNum = rowNum + 1
outputWs.Cells(rowNum, 1).Value = cell.Address(False, False)
outputWs.Cells(rowNum, 2).Value = cell.Formula
End If
Next cell
MsgBox "Formula cell addresses listed on sheet: " & outputWs.Name
End Sub
This scans the active sheet, creates a new sheet called "FormulaCells," and lists each formula cell’s address and its formula.