+ -
当前位置:首页 → 问答吧 → 请各位老师,帮我写一单元格对齐方式代码!

请各位老师,帮我写一单元格对齐方式代码!

时间:2011-08-02

来源:互联网

我要把sheet2.[b1:d15]的单元格对齐方式,水平设为右对齐,垂直设为居中对齐。请老师帮我写一代码,谢谢!

作者: 7016427   发布时间: 2011-08-02

录制一下宏试试。。。

作者: jiminyanyan   发布时间: 2011-08-02

Sub Macro1()
'
' Macro1 Macro
' 宏由 system 录制,时间: 2011-8-2
    Sheet2.Range("B1:D15").Select
    With Selection
        .HorizontalAlignment = xlRight
        .VerticalAlignment = xlCenter
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
End Sub

作者: flysum2008   发布时间: 2011-08-02

我测试很好!你能否解释吗?

作者: 7016427   发布时间: 2011-08-02

Sub Macro1()
'
' Macro1 Macro
' 宏由 system 录制,时间: 2011-8-2
    Sheet2.Range("B1:D15").Select
    With Selection
        .HorizontalAlignment = xlRight   '水平右对齐
        .VerticalAlignment = xlCenter   '垂直居中对齐。。。下面的不要也没关系。。。
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
End Sub

作者: jiminyanyan   发布时间: 2011-08-02

ok!

作者: 7016427   发布时间: 2011-08-02