
Highlighting like names in a range
Quote:
>I have a range named AllNames on a sheet. The range is several columns wide
>and several rows down. The range is actually laid out in a calendar format
>which will be used for work scheduling. Once the schedule is set, there
>will be several names per day listed. There is only 1 name per cell. The
>names will be repeated many times throughout the range. I would like to be
>able to print out a schedule for each person with only their name
>highlighted, but I only know how to do it if I loop through and select each
>cell in the range and test it for the correct name. It would be greatly
>appreciated if someone could get me started with something like:
>For Each cell In AllNames
>If cell ="Cheryl" Then
>' All the highlighting stuff
>End If
>Next
>Thanks,
>Phil
Try conditional formatting.
Here's an example with the range named "Calendar"
Watch out for inadvertent line feeds induced by the news reader.
====================
Option Explicit
Sub Hname()
Dim NM As String
NM = InputBox("Name to Highlight")
Range("Calendar").FormatConditions.Delete
Range("Calendar").FormatConditions.Add Type:=xlCellValue,
Operator:=xlEqual, _
Formula1:="=""" & NM & """"
With Range("Calendar").FormatConditions(1).Font
.Bold = True
.Italic = False
End With
End Sub
==================
--ron