ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Is the formula an array formula? (https://www.excelbanter.com/excel-programming/321506-formula-array-formula.html)

Jason Morin[_3_]

Is the formula an array formula?
 
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


Tom Ogilvy

Is the formula an array formula?
 
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

--
Regards,
Tom Ogilvy

"Jason Morin" wrote in message
...
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




Don Guillett[_4_]

Is the formula an array formula?
 
try this idea
Sub ifarray()
For Each c In Selection
If c.HasArray Then MsgBox c.Address
Next
End Sub

--
Don Guillett
SalesAid Software

"Jason Morin" wrote in message
...
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




Dave Peterson[_5_]

Is the formula an array formula?
 
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.

Jason Morin wrote:

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


--

Dave Peterson


All times are GMT +1. The time now is 05:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com