在Excel VBA中,我试图将参数值传递给属性“ VerticalAlignment”。我得到的错误是:“无法设置Range类的HorizontalAlignment属性”。显然问题出在'horzAlign'和'vertAlign'值上,但是,那又是什么呢?
' Merge the range & horizontal & vertical
' alignment as per arguments
Sub mergeCellsWithLeftAlign(ByVal curRange As Range, _
ByVal horzAlign As String, ByVal vertAlign As String)
With curRange
.HorizontalAlignment = horzAlign
.VerticalAlignment = vertAlign
.MergeCells = True
End With
End Sub
这是在另一个过程中调用的,如下所示:
Call mergeCellsWithLeftAlign(Range("F10:F11"), "xlLeft", "xlBottom")
查看VBA帮助,这些值不能为"xlLeft", "xlBottom"
but xlLeft, xlBottom
,即不带引号-它们是整数常量。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句