View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Sheeloo[_3_] Sheeloo[_3_] is offline
external usenet poster
 
Posts: 1,805
Default Alphabetically list of names BOLD and NOT bold

Following macro will BOLD the first letter on Last Names in Col A in
alternate way as desired by you...

Use this macro;
' See http://www.rondebruin.nl/code.htm if you need help on how to run macros

Sub highlight()
Dim lastRow, lastCol As Double
Dim pName As String
Dim flg As Boolean

With ActiveSheet
lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
lastCol = .Cells(.Columns.Count, "A").End(xlToLeft).Column
End With

pName = ""
flg = True

For i = 2 To lastRow

If pName < Left(Cells(i, 1).Value, 1) Then
pName = Left(Cells(i, 1).Value, 1)
If flg = True Then
flg = False
Else
flg = True
End If

End If

If flg = True Then
'format

With Cells(i, 1).Characters(Start:=1, Length:=1).Font
.FontStyle = "Bold"
End With
With Cells(i, 1).Characters(Start:=2, Length:=255).Font
.FontStyle = "Regualar"
End With

End If

Next

End Sub

"Lerner" wrote:

Hi, Shane, thanks for your help, however only the first name gets to be bold
using the given formula.
Clarification: There are more than one last name starting with letter A
and/or other letters.
Also, not only last names starting with letter C could be missing, it could be
last names starting with any other letter.
ex
A2 ABILA, JOHN
A3 ANARASCO, JESUS
A4 ANTIARO, JANE
A5 CORALIO, MIKE
A6 CORANIO, NICK
In this example last names starting with letter B are missing, like I said
it could be any letter as I will be applying the CF to different
worksheets with different lists.
THANKS.

"Shane Devenshire" wrote:

Hi,

Lest assume that the last names are in A2:A100 with a title in cell A1, then

To conditionally format your cell(s):

In 2003:
1. Select the cells you want to format (here A2:A100)
2. Choose Format, Conditional Formatting
3. Choose Formula is from the first drop down
4. In the second box enter the formula:
=IF(ROW()=2,TRUE,IF(LEFT(A2)=LEFT(A1),C1,NOT(C1)))
5. Click the Format button
6. Choose a color on the Patterns tab (or any available option)
7. Click OK twice.

In 2007:
1. Highlight all the cells on the rows you want formatted
2. Choose Home, Conditional Formatting, New Rule
3. Choose Use a formula to determine which cell to format
4. In the Format values where this formula is true enter the following
formula:
=IF(ROW()=2,TRUE,IF(LEFT(A2)=LEFT(A1),C1,NOT(C1)))
5. Click the Format button and choose a format.
6. Click OK twice

--
If this helps, please click the Yes button.

Cheers,
Shane Devenshire


"Lerner" wrote:

I have a list of alphabetically last names, first names sorted that I' like to
conditionally format by BOLDED or NOT bolded.
All last names startin with letter A = BOLD
Going down then B = not bold
Then last name starting with letter C could be missing or not:
If C last names present then C=BOLD
If C does not have any last names then D=BOLD.
And so on.
I've trying conditionally formatting making up formula is... but nothing
works.
Column A
XL 2003
Windows XP.
THANKS.