Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default simple: type mismatch

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default simple: type mismatch

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.

--
Chris Marlow
MCSD.NET, Microsoft Office XP Master


"mark kubicki" wrote:

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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Type Mismatch?? Otto Moehrbach Excel Programming 4 December 28th 05 03:03 PM
Type mismatch using rnge as Range with Type 8 Input Box STEVE BELL Excel Programming 11 December 3rd 05 05:02 AM
Type mismatch ! Roshintosh Excel Programming 7 November 10th 05 07:13 PM
Help: Compile error: type mismatch: array or user defined type expected lvcha.gouqizi Excel Programming 1 October 31st 05 08:20 PM
Type mismatch Alan Beban[_4_] Excel Programming 0 February 4th 04 08:39 PM


All times are GMT +1. The time now is 01:36 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"