如何为下面的代码对齐(居中)我的单元格值?
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
请提前帮助,谢谢。
答案 0 :(得分: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