View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
jfcby[_2_] jfcby[_2_] is offline
external usenet poster
 
Posts: 121
Default Worksheet Range Question - Excel 2003

Hello,

On worksheet 1 my range name will be NAMES, there will be about 25. On
worksheet 2 there will be 100 different names on A3:K3. I would like to
have a background color in the cells that have the range names?

This is the macro error message I'm getting:

Run-Time Error '13':
Type Mismatch

This is the line the Debug highlights:

If mycell.Value = Range("MACROS!NAME") Then

Here is the macro code:

Sub ColorBackground2()
'Color background of specfic words
Dim Rng As Range
Dim mycell
Set Rng = ActiveSheet.Range("D7:D22")
For Each mycell In Rng
If mycell.Value = Range("MACROS!NAME") Then '<< ERROR ON THIS LINE
mycell.Select
With Selection
mycell.Interior.ColorIndex = 35
mycell.Interior.Pattern = xlSolid
End With

End If
Next mycell
End Sub

Thanks for help in advance
Frankie