Range Selection help (Formatting)

R

Rick S.

I select a range in a row and begin formatting per the code below, I am
having trouble getting this code to work.
It will find the first cell with "TRG" but none of the others? It appears
to complete the Font changes but not the alignment changes (less the first
cell with "TRG").
'======
Range("F10:F29").Select
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="=""TRG#"""

Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Bold = True
.Italic = True
.TintAndShade = 0
End With
With Selection
If Left(ActiveCell.Value, 3) = "TRG" Then
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
End If
End With
Selection.FormatConditions(1).StopIfTrue = False
Range("D10").Select
'======
--
Regards

VBA.Noob.Confused
XP Pro
Office 2007
 
R

Rick S.

I think I see what is wrong, I am stepping thru each cell?
--
Regards

VBA.Noob.Confused
XP Pro
Office 2007
 
R

Rick S.

Last reply was NOT stepping thru each cell.
I believe am now.
'======
Range("F10:F29").Select
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="=""TRG#"""

Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Bold = True
.Italic = True
.TintAndShade = 0
End With
For Each c In Selection
If Left(c.Value, 3) = "TRG" Then
c.HorizontalAlignment = xlGeneral
c.VerticalAlignment = xlBottom
End If
Next c
Selection.FormatConditions(1).StopIfTrue = False
Range("D10").Select
'======
So much to learn!
--
Regards

VBA.Noob.Confused
XP Pro
Office 2007
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top