By: Lutfor Rahman Shimanto

In reply to ML.

Dear, Thanks for pointing out the fact! You are right. The Alignment tab in the Format Cells dialog box is unavailable when setting up conditional formatting rules. So, using the conditional formatting option for text alignment is impossible.

Don’t worry! There is an idea of using an Excel VBA event procedure. Please check the following:

The event procedure will trigger when range B2:B7 is changed. If the cell value is Red, it will apply left alignment. For Blue, it will be center alignment; for the other values, it will apply left alignment.

Excel VBA Event Procedure:

Private Sub Worksheet_Change(ByVal Target As Range)

Dim cell As Range

Dim targetRange As Range
Set targetRange = Me.Range("B2:B7")

If Not Intersect(Target, targetRange) Is Nothing Then
For Each cell In Intersect(Target, targetRange)

If cell.Value = "Red" Then
cell.HorizontalAlignment = xlLeft
ElseIf cell.Value = "Blue" Then
cell.HorizontalAlignment = xlCenter
Else
cell.HorizontalAlignment = xlRight
End If
Next cell
End If

End Sub

Hopefully, the solution will fulfil your goal. I have attached the solution workbook as well. Good luck.

DOWNLOAD SOLUTION WORKBOOK

Regards
Lutfor Rahman Shimanto
Excel & VBA Developer
ExcelDemy