Is the formula an array formula?

J

Jason Morin

I'd like to insert a cell's formula into a comment. My
only issue is testing to see if it's an array formula or
normal formula. As of now, the macro always says it's an
array formula. Thanks for any help you can provide.

Sub FormulaInComment()
Dim ConfirmBox As String
Dim FormulaType As String
ConfirmBox = MsgBox("Proceed?", vbYesNo)
If ConfirmBox = vbNo Then Exit Sub
With ActiveCell
If .HasFormula Then
If IsNull(.FormulaArray) Then
FormulaType = "Formula:"
Else
FormulaType = "Array Formula:"
End If
Else
MsgBox "No formula in cell!"
Exit Sub
End If
.AddComment
.Comment.Text Text:=FormulaType & Chr(10) & .Formula
.Comment.Visible = False
.Copy
.PasteSpecial (xlPasteValues)
End With
Application.CutCopyMode = False
End Sub
 
T

Tom Ogilvy

Sub FormulaInComment()
Dim ConfirmBox As String
Dim FormulaType As String
ConfirmBox = MsgBox("Proceed?", vbYesNo)
If ConfirmBox = vbNo Then Exit Sub
With ActiveCell
If .HasFormula Then
If Not .HasArray Then
FormulaType = "Formula:"
Else
FormulaType = "Array Formula:"
End If
Else
MsgBox "No formula in cell!"
Exit Sub
End If
.AddComment
.Comment.Text Text:=FormulaType & Chr(10) & .Formula
.Comment.Visible = False
.Copy
.PasteSpecial (xlPasteValues)
End With
Application.CutCopyMode = False
End Sub
 
D

Don Guillett

try this idea
Sub ifarray()
For Each c In Selection
If c.HasArray Then MsgBox c.Address
Next
End Sub
 
D

Dave Peterson

I had one of these thingies in a workbook. I thought it would be very useful to
document what happened before (and if I had to revert).

If you're thinking of doing the same thing, you may want to use .formular1c1

I inserted rows (not columns) in my data and every "retrieved" formula was now
pointing at the correct column in the wrong row.

It was not as useful as I hoped.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top