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 / February 2006

Tip: Looking for answers? Try searching our database.

simple: type mismatch

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mark kubicki - 21 Feb 2006 18:42 GMT
feel like an idiot that i can't get this one right... never-the-less...

B3:B10 have no special format, and could either have text, or be null

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Not Intersect(Target, ActiveSheet.Range("B3:B10")) Is Nothing Then
        If Len(trim(Range(Target.Address).Value) )= 0 Then
           Target.Interior.ColorIndex = 53
        Else
           Target.Interior.ColorIndex = 36
        End If
   End If
End Sub

run time error 13
type mismatch

thanks in advance,
mark
Chris Marlow - 21 Feb 2006 19:01 GMT
Mark,

Not sure exactly what you are trying to do, but;

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
   
   Dim ranRange As Range
   
   For Each ranRange In Target.Cells
   
        If Not Intersect(ranRange, ActiveSheet.Range("B3:B10")) Is Nothing
Then
            If Len(Trim(Range(ranRange.Address).Value)) = 0 Then
               Target.Interior.ColorIndex = 53
            Else
               Target.Interior.ColorIndex = 36
            End If
       End If

   Next ranRange
   
End Sub

Gives no error ... the important bit I guess is that when you do the 'Trim'
the range is one cell (which the for each ensures).

Regards,

Chris.

Signature

Chris Marlow
MCSD.NET, Microsoft Office XP Master

> feel like an idiot that i can't get this one right... never-the-less...
>
[quoted text clipped - 15 lines]
> thanks in advance,
> mark
 
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.