Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default detecting formula containing a constant

Hi

Is there a way to detect formula on a sheet that contain a constant?
For example if a sheet contains formulas like

=A1*10 or =A1+10

Then I would like to change the font color of those cells to red to
flag them.

Utkarsh

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default detecting formula containing a constant

Try this out:

Sub markum()
' gsnu
Set r = ActiveSheet.UsedRange
Set rf = r.SpecialCells(xlFormulas)
c = Chr(10)
s = Array("=", "+", "-", "*", "/", "^")

For Each rr In rf
v = rr.Formula
For i = 0 To 5
v = Replace(v, s(i), c)
Next
v = Replace(v, "(", "")
v = Replace(v, ")", "")
frags = Split(v, c)
For i = LBound(frags) To UBound(frags)
If IsNumeric(frags(i)) Then
rr.Font.ColorIndex = 3
End If
Next
Next
End Sub


Basically we take each equation and break it into fragments. Then test each
fragment to see if it is a number.

Let me know if you have a formula that doesn't match this code.
--
Gary''s Student
gsnu200707


"Utkarsh" wrote:

Hi

Is there a way to detect formula on a sheet that contain a constant?
For example if a sheet contains formulas like

=A1*10 or =A1+10

Then I would like to change the font color of those cells to red to
flag them.

Utkarsh


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
formula vs constant rk0909 Excel Discussion (Misc queries) 1 January 14th 10 03:03 AM
Formula for Detecting Currency Format Tiziano Excel Worksheet Functions 1 September 3rd 07 06:49 AM
Formula for detecting a certain pattern in a particular row or column? [email protected] Excel Programming 2 February 7th 07 10:23 PM
Detecting changes in results of formula spacecityguy[_9_] Excel Programming 3 January 27th 06 09:03 PM
Create formula for detecting duplicates Courtneyf04 Excel Worksheet Functions 1 June 7th 05 09:47 PM


All times are GMT +1. The time now is 05:37 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"