ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   test for a formula (https://www.excelbanter.com/excel-discussion-misc-queries/47002-test-formula.html)

lashio

test for a formula
 
Will someone help me write a macro to check if a selected cell contains a
formula. Please



Norman Jones

Hi Lashio,

Try something like:

'=================
Public Sub FormulaTest()
If ActiveCell.HasFormula Then
'Do something, e.g.:
MsgBox "Cell " & ActiveCell.Address(0, 0) _
& " is a formula cell"
Else
'do something else, e.g.:
MsgBox "Cell " & ActiveCell.Address(0, 0) _
& " is not a formula cell"
End If
End Sub
'<<=================

---
Regards,
Norman



"lashio" wrote in message
...
Will someone help me write a macro to check if a selected cell contains a
formula. Please




lashio

Hi Norman,
Thank you very much, that's what I needed.

"Norman Jones" wrote in message
...
Hi Lashio,

Try something like:

'=================
Public Sub FormulaTest()
If ActiveCell.HasFormula Then
'Do something, e.g.:
MsgBox "Cell " & ActiveCell.Address(0, 0) _
& " is a formula cell"
Else
'do something else, e.g.:
MsgBox "Cell " & ActiveCell.Address(0, 0) _
& " is not a formula cell"
End If
End Sub
'<<=================

---
Regards,
Norman



"lashio" wrote in message
...
Will someone help me write a macro to check if a selected cell contains
a formula. Please







All times are GMT +1. The time now is 02:27 PM.

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