Re: Centering Text Not Working
- From: Gord Dibben <gorddibbATshawDOTca>
- Date: Tue, 20 Dec 2005 16:32:01 -0800
Steve
Font doesn't have an alignment property.
You can End With after the 2 alignment lines and then start another With
statement for the Font or just amend as follows.
Private Sub AAA1_Click()
If Range("A1") = 1 Then
Range("A1").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.Font.ColorIndex = 3
.Font.FontStyle = "Bold"
End With
With Selection.Interior
.ColorIndex = 1
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
Else
Range("A1").Select
With Selection.Interior
.ColorIndex = 29
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
End If
End Sub
Gord Dibben Excel MVP
On Tue, 20 Dec 2005 15:48:02 -0800, caldog <caldog@xxxxxxxxxxxxxxxxxxxxxxxxx>
wrote:
>I have this code that bolds and that puts color as background if certain
>conditions are met. What is not happening is that the text centering line is
>erroring out. Can somebody explain why this is.
>
>Steve
>
>Private Sub AAA1_Click()
>
>If Range("A1") = 1 Then
> Range("A1").Select
> With Selection.Font
> .HorizontalAlignment = xlCenter - "Line not working"
> .VerticalAlignment = xlCenter - "Line not working"
> .ColorIndex = 3
> .FontStyle = "Bold"
> End With
> With Selection.Interior
> .ColorIndex = 1
> .Pattern = xlSolid
> .PatternColorIndex = xlAutomatic
> End With
>Else
> Range("A1").Select
> With Selection.Interior
> .ColorIndex = 29
> .Pattern = xlSolid
> .PatternColorIndex = xlAutomatic
> End With
>End If
.
- Follow-Ups:
- Re: Centering Text Not Working
- From: caldog
- Re: Centering Text Not Working
- Prev by Date: Re: Possible to sort part of a cell?
- Next by Date: programming for advanced filter using external criteria file
- Previous by thread: Re: Centering Text Not Working
- Next by thread: Re: Centering Text Not Working
- Index(es):
Relevant Pages
|