0

以下のコードのセルの値を揃える (中央に配置する) にはどうすればよいですか?

For x = 0 To EleXML.ChildNodes.Length - 1    
      Range("A10").offset(x,0) = EleXML.ChildNodes.Item(x).getAttribute("aa")
      Range("A10").offset(x,0) = EleXML.ChildNodes.Item(x).getAttribute("bb")
      Range("A10").offset(x,0) = EleXML.ChildNodes.Item(x).getAttribute("cc")
Next x

助けてください、事前に感謝します。

4

1 に答える 1

0

それはあなたが探しているものですか?

s = 1
For x = 0 To EleXML.ChildNodes.Length - 1
    Range("A10").Offset(s, 0) = EleXML.ChildNodes.Item(x).getAttribute("aa")
    Range("A10").Offset(s + 1, 0) = EleXML.ChildNodes.Item(x).getAttribute("bb")
    Range("A10").Offset(s + 2, 0) = EleXML.ChildNodes.Item(x).getAttribute("cc")
    s = s + 3
Next x

コードを記録することで、これを理解できます。

Sub Macro1()
'
' Macro1 Macro
'

'
    With Selection
        .HorizontalAlignment = xlLeft
        .VerticalAlignment = xlBottom
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlBottom
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    With Selection
        .HorizontalAlignment = xlRight
        .VerticalAlignment = xlBottom
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
End Sub

これを試して。必要に応じてこれを調整できます。

With Range("A10").Offset(x, 0)
    .HorizontalAlignment = xlLeft
    .VerticalAlignment = xlBottom
    .WrapText = False
    .Orientation = 0
    .AddIndent = False
    .IndentLevel = 0
    .ShrinkToFit = False
    .ReadingOrder = xlContext
    .MergeCells = False
End With
于 2013-05-29T12:44:19.727 に答える