View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default Conditional Formatting using VBA

On Thu, 3 Mar 2005 03:43:03 -0800, JWCardington
wrote:

Ron,
Thank you very much. This works great if all I am doing is typing the
numbers into cell b1. But the number that will populate b1 is the result of
a "sum" formula that totals the number in another range, say c1:d1 for
example. This doesnt work if I put my formula in cell b1.

What else do I need?


What does "doesn't work" mean?

The way you have written the VBA routine, it will only "do something" if and
only if Target is B1. But Target represents the changed range but not if the
change is the result of a calculation.

Since B1 contains a formula that changes as the result of entries in C1:D1,
your Sub your first "IF" statement will evaluate as FALSE, and the Sub will
exit.

2 possible solutions:

1. Forget the IF statement. Evaluate B1 after every Change (or calculate)
event.

2. Change the IF statement to look at the Precedents of B1:

================================
....
If Not Intersect(Target, Range("C1:D1")) Is Nothing Then
With [B1]
Select Case .Value
....
===============================


--ron