PC Review


Reply
Thread Tools Rate Thread

Conditional Formatting and Text Alignment

 
 
Rick S.
Guest
Posts: n/a
 
      12th Feb 2008
How can I set the text alignment based on the cell value in the same manner
as Conditional Formatting?

'======Conditional text formatting
Range("F10:F30").Select
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="=""TPG#"""

Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Bold = True
.Italic = True
.TintAndShade = 0
End With
'======

Its easy to do in an "IF" statement, but that only works when the macro is
played.

I need the cell to align left when "TPG" is found in the cell. Conditional
formatting doesn't allow for alignment like it does for text formatting.

--
Regards

VBA.Noob.Confused
XP Pro
Office 2007

 
Reply With Quote
 
 
 
 
JNW
Guest
Posts: n/a
 
      12th Feb 2008
You could trigger the macro on the worksheet change event.
--
JNW


"Rick S." wrote:

> How can I set the text alignment based on the cell value in the same manner
> as Conditional Formatting?
>
> '======Conditional text formatting
> Range("F10:F30").Select
> Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
> Formula1:="=""TPG#"""
>
> Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
> With Selection.FormatConditions(1).Font
> .Bold = True
> .Italic = True
> .TintAndShade = 0
> End With
> '======
>
> Its easy to do in an "IF" statement, but that only works when the macro is
> played.
>
> I need the cell to align left when "TPG" is found in the cell. Conditional
> formatting doesn't allow for alignment like it does for text formatting.
>
> --
> Regards
>
> VBA.Noob.Confused
> XP Pro
> Office 2007
>

 
Reply With Quote
 
Rick S.
Guest
Posts: n/a
 
      12th Feb 2008
I was afraid of having to do just that. I have too many sheets and too many
workbooks and too little time. LOL
--
Regards

VBA.Noob.Confused
XP Pro
Office 2007



"JNW" wrote:

> You could trigger the macro on the worksheet change event.
> --
> JNW
>
>
> "Rick S." wrote:
>
> > How can I set the text alignment based on the cell value in the same manner
> > as Conditional Formatting?
> >
> > '======Conditional text formatting
> > Range("F10:F30").Select
> > Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
> > Formula1:="=""TPG#"""
> >
> > Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
> > With Selection.FormatConditions(1).Font
> > .Bold = True
> > .Italic = True
> > .TintAndShade = 0
> > End With
> > '======
> >
> > Its easy to do in an "IF" statement, but that only works when the macro is
> > played.
> >
> > I need the cell to align left when "TPG" is found in the cell. Conditional
> > formatting doesn't allow for alignment like it does for text formatting.
> >
> > --
> > Regards
> >
> > VBA.Noob.Confused
> > XP Pro
> > Office 2007
> >

 
Reply With Quote
 
JNW
Guest
Posts: n/a
 
      12th Feb 2008
If only we could use VBA to stop time...

If the command works for all worksheets in a workbook you could also use the
workbook change event (I think it exists)

If the command works for all workbooks you use, put it in your personal.xls
file.
--
JNW


"Rick S." wrote:

> I was afraid of having to do just that. I have too many sheets and too many
> workbooks and too little time. LOL
> --
> Regards
>
> VBA.Noob.Confused
> XP Pro
> Office 2007
>
>
>
> "JNW" wrote:
>
> > You could trigger the macro on the worksheet change event.
> > --
> > JNW
> >
> >
> > "Rick S." wrote:
> >
> > > How can I set the text alignment based on the cell value in the same manner
> > > as Conditional Formatting?
> > >
> > > '======Conditional text formatting
> > > Range("F10:F30").Select
> > > Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
> > > Formula1:="=""TPG#"""
> > >
> > > Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
> > > With Selection.FormatConditions(1).Font
> > > .Bold = True
> > > .Italic = True
> > > .TintAndShade = 0
> > > End With
> > > '======
> > >
> > > Its easy to do in an "IF" statement, but that only works when the macro is
> > > played.
> > >
> > > I need the cell to align left when "TPG" is found in the cell. Conditional
> > > formatting doesn't allow for alignment like it does for text formatting.
> > >
> > > --
> > > Regards
> > >
> > > VBA.Noob.Confused
> > > XP Pro
> > > Office 2007
> > >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Word text copied into email loses formatting alignment Doug Robbins - Word MVP Microsoft Word Document Management 0 26th Nov 2009 02:47 AM
Word text copied into email loses formatting alignment Heather Microsoft Word Document Management 0 25th Nov 2009 11:39 PM
Conditional Formatting of text effecting formatting of background =?Utf-8?B?SEFI?= Microsoft Access Reports 6 25th Mar 2008 06:23 PM
Conditional Formatting to Change Cell Alignment? =?Utf-8?B?U2FtIENoYW1iZXJz?= Microsoft Excel Misc 3 11th Jun 2007 04:10 PM
Formatting alignment - can I show text upside down? =?Utf-8?B?UGhpbGluTG9uZG9u?= Microsoft Excel Misc 5 13th Nov 2006 03:24 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:33 AM.