By: Lutfor Rahman Shimanto

In reply to M_curious.

Hello there! Thanks for sharing an exciting problem. Since using the conditional formatting option for text alignment is impossible, you can only use an Excel VBA procedure.

Note: 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. You can modify the code based on your needs.

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. Download the attached solution workbook for a better understanding.

DOWNLOAD SOLUTION WORKBOOK

Regards
Lutfor Rahman Shimanto
Excel & VBA Developer
ExcelDemy