View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
Chris Berry Chris Berry is offline
external usenet poster
 
Posts: 1
Default Whether a Cell contains a Formula


Roger Wrote:
What function can be used to determine whether a cell contains a
formula?

Thanks in advance for your help.

Roger


I picked up this from Jwalk.com and thought it was pretty neat.


Code:
--------------------
Sub QuickMap()
If TypeName(ActiveSheet) < "Worksheet" Then Exit Sub
' Create object variables for cell subsets
On Error Resume Next
Set FormulaCells = Range("A1").SpecialCells _
(xlFormulas, xlNumbers + xlTextValues + xlLogical)
Set TextCells = Range("A1").SpecialCells(xlConstants, xlTextValues)
Set NumberCells = Range("A1").SpecialCells(xlConstants, xlNumbers)
On Error GoTo 0

' Add a new sheet and format it
Sheets.Add
With Cells
.ColumnWidth = 2
.Font.Size = 8
.HorizontalAlignment = xlCenter
End With

Application.ScreenUpdating = False

' Do the formula cells
If Not IsEmpty(FormulaCells) Then
For Each Area In FormulaCells.Areas
With ActiveSheet.Range(Area.Address)
.Value = "F"
.Interior.ColorIndex = 3
End With
Next Area
End If

' Do the text cells
If Not IsEmpty(TextCells) Then
For Each Area In TextCells.Areas
With ActiveSheet.Range(Area.Address)
.Value = "T"
.Interior.ColorIndex = 4
End With
Next Area
End If

' Do the numeric cells
If Not IsEmpty(NumberCells) Then
For Each Area In NumberCells.Areas
With ActiveSheet.Range(Area.Address)
.Value = "N"
.Interior.ColorIndex = 6
End With
Next Area
End If
End Sub



--------------------


He offers it up as a tip but I think it's also included in his utility
pack.


--
Chris Berry
------------------------------------------------------------------------
Chris Berry's Profile: http://www.excelforum.com/member.php...o&userid=36165
View this thread: http://www.excelforum.com/showthread...hreadid=567403