Public Sub 技巧4_151()
Dim myRange As Range
Set myRange = Range("A1") '指定任意单元格
With myRange
.Value = "ExcelVBA实用技巧大全"
.HorizontalAlignment = xlRight
MsgBox "水平右对齐。"
.HorizontalAlignment = xlLeft
MsgBox "水平左对齐。"
.HorizontalAlignment = xlCenter
MsgBox "水平居中。"
.HorizontalAlignment = xlDistributed
MsgBox "水平分散对齐。"
.VerticalAlignment = xlTop
MsgBox "垂直靠上。"
.VerticalAlignment = xlBottom
MsgBox "垂直靠下。"
.VerticalAlignment = xlCenter
MsgBox "垂直居中。"
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlGeneral
MsgBox "恢复默认。"
End With
Set myRange = Nothing
End Sub