Highlighting like names in a range 
Author Message
 Highlighting like names in a range

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



Mon, 07 Feb 2005 08:57:18 GMT  
 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



Mon, 07 Feb 2005 09:40:15 GMT  
 Highlighting like names in a range
Thanks Ron.  I never thought of conditional formatting.
Phil


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



Mon, 07 Feb 2005 10:04:48 GMT  
 Highlighting like names in a range


Quote:
>Thanks Ron.  I never thought of conditional formatting.
>Phil

You're welcome.

--ron



Mon, 07 Feb 2005 10:44:56 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Highlight Named Ranges

2. Highlight Name Ranges

3. highlight range without knowing the range beforehand

4. Changing the size of a named range, and assigning the original name to the new range

5. Assigning a Range Name to a variable range

6. Using Named Ranges in Range(Cells(...)...)

7. Copy data in a named range to variable range area

8. Reference to named range failing for range set to a value

9. VBA :Selecting ranges that vary, Naming ranges based on Formatting

10. Specify range within Named Range?


 
Powered by phpBB® Forum Software © phpBB Group