Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How to tell whether a cell contains a formula?

if all the formulas would refer to cells on the same sheet.

Sub MarkCells()
Dim rng As Range
Dim rng1 As Range
Dim cell As Range
On Error Resume Next
Set rng = ActiveSheet.Cells.SpecialCells(xlFormulas)
On Error GoTo 0
If Not rng Is Nothing Then
For Each cell In rng
Set rng1 = Nothing
On Error Resume Next
Set rng1 = cell.DirectPrecedents
On Error GoTo 0
If Not rng1 Is Nothing Then
cell.Interior.ColorIndex = 3
End If
Next
End If

End Sub


Regards,
Tom Ogilvy


"Seihee" wrote in message
...
Hi!

I'm writing a macro to examine all cells in a worksheet.
If a cell contains a "pure formula" referencing other
cells, then I want to change the color of the cell that
contains a formula.

In a macro, is there any way I can tell whether a cell
contains a formula rather than pure values (number,
literal, etc.)?

By "pure formula", I mean a formula that contain a cell
reference. In other words, "=b5+k2" will be considered a
formula but "=5+28/4" will not for my purposes.

Your help will be greatly appreciated.

Thanks,
Seihee



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I make a blank cell in a formula cell with a range of cell Vi Excel Discussion (Misc queries) 5 June 21st 07 02:46 PM
adding a formula in a cell but when cell = 0 cell is blank Mike T Excel Worksheet Functions 5 May 31st 05 01:08 AM
Cell Formula reference to cell Based On third Cell Content Gabriel Excel Discussion (Misc queries) 1 February 11th 05 06:36 AM
Cell Formula reference to cell Based On third Cell Content Gabriel Excel Discussion (Misc queries) 0 February 11th 05 05:35 AM
Question: Cell formula or macro to write result of one cell to another cell Frederik Romanov Excel Programming 1 July 8th 03 03:03 PM


All times are GMT +1. The time now is 01:10 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"