Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2008

Tip: Looking for answers? Try searching our database.

Range Selection help (Formatting)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rick S. - 28 Jan 2008 20:56 GMT
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
'======
Signature

Regards

VBA.Noob.Confused
XP Pro
Office 2007

Rick S. - 28 Jan 2008 21:05 GMT
I think I see what is wrong, I am stepping thru each cell?
Signature

Regards

VBA.Noob.Confused
XP Pro
Office 2007

> I select a range in a row and begin formatting per the code below, I am
> having trouble getting this code to work.
[quoted text clipped - 21 lines]
>     Range("D10").Select
> '======
Rick S. - 28 Jan 2008 21:11 GMT
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!
Signature

Regards

VBA.Noob.Confused
XP Pro
Office 2007

> I think I see what is wrong, I am stepping thru each cell?
>
[quoted text clipped - 23 lines]
> >     Range("D10").Select
> > '======
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.