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 / November 2007

Tip: Looking for answers? Try searching our database.

Find and colour all cells with Validation

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
BEEJAY - 27 Nov 2007 15:53 GMT
Looking for VBA that will turn cells blue, if they have any validation rules
applied to it. Is this possible?
How?
I have something similar that makes all unlocked cells Yellow. It works like
a charm and is lightning fast.
But I don't know enough coding to change that code to suit this application.

    Dim cell As Range, tempR As Range, rangeToCheck As Range
       Cells.Select
       Cells.Interior.ColorIndex = -4142
       For Each cell In Intersect(Selection, _
               ActiveSheet.UsedRange)

'    If cell has validation then colour cell blue
Code needed here: <<<?  

Old Code (If Not cell.Locked Then
          If tempR Is Nothing Then
            Set tempR = cell
               Else
                       Set tempR = Union(tempR, cell)
               End If
           End If

       Next cell
           If tempR Is Nothing Then
           MsgBox "There are no Cells with Validation " & _
                   "in the selected range."
           End
       End If
       
   'Select qualifying cells
   'TempR.Select
       tempR.Interior.ColorIndex = 5 'Blue

End Sub
Bernie Deitrick - 27 Nov 2007 16:32 GMT
BEEJAY,

Cells.SpecialCells(xlCellTypeAllValidation).Interior.ColorIndex = 5

DO NOT use the "For Each cell in ...."  construct.  There is no need for it with this code.

HTH,
Bernie
MS Excel MVP

> Looking for VBA that will turn cells blue, if they have any validation rules
> applied to it. Is this possible?
[quoted text clipped - 32 lines]
>
> End Sub
 
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.