Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2006

Tip: Looking for answers? Try searching our database.

Change cells color & cells contains if formula

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
dot - 24 Jan 2006 12:47 GMT
I'm new to excel vba. I'm tried out the vba code for changing cells
color but it don't work if my cells contains a if formula (eg. all
cells in cloumn A contain =if(and(b1="Rej",c1="Rej"),"Rej",....). Any
idea what should be the code?
Kevin B - 24 Jan 2006 13:34 GMT
Perhaps this little code snippet will point you in the right direction:

Sub FormulaCellColor()

   Dim varVal As Variant
   Dim strCell As String
   Dim r As Range
   
   Range("A1").Select
   varVal = ActiveCell.Value
   
   Do Until varVal = ""
       Set r = ActiveCell
       If r.HasFormula Then
           With r
               .Interior.Color = vbBlue
               .Font.Color = vbWhite
           End With
       End If
       ActiveCell.Offset(1).Select
   Loop
   
   Set r = Nothing

End Sub

Signature

Kevin Backmann

> I'm new to excel vba. I'm tried out the vba code for changing cells
> color but it don't work if my cells contains a if formula (eg. all
> cells in cloumn A contain =if(and(b1="Rej",c1="Rej"),"Rej",....). Any
> idea what should be the code?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.