PC Review


Reply
Thread Tools Rate Thread

detecting formula containing a constant

 
 
Utkarsh
Guest
Posts: n/a
 
      22nd Feb 2007
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 With Quote
 
 
 
 
=?Utf-8?B?R2FyeScncyBTdHVkZW50?=
Guest
Posts: n/a
 
      22nd Feb 2007
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 With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
formula vs constant rk0909 Microsoft Excel Misc 1 14th Jan 2010 03:03 AM
Re: Set a constant from a formula in VBA Dave Peterson Microsoft Excel Misc 0 1st Dec 2006 01:31 AM
Formula is evaluated as a constant instead of a formula jb Microsoft Excel Programming 2 28th Aug 2006 09:20 PM
Formula Constant =?Utf-8?B?ZGFsZTE5NDg=?= Microsoft Excel Worksheet Functions 2 2nd Nov 2005 09:44 PM
Constant in Formula Sige Microsoft Excel Programming 27 28th Sep 2005 08:21 AM


Features
 

Advertising
 

Newsgroups
 


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