因此,我在 vba 中执行了一项相对简单的任务,但对结果摸不着头脑。我编写了一个列标题数组,然后尝试通过 Application.WorksheetFunction.Transpose 函数粘贴它们,但没有运气......它只是将数组中的第一个值粘贴到范围的长度。
这是我的代码:
<i> sub test
Dim myHeadings() As Variant
Dim header_rng As Range
myHeadings = Array("a", "b" , "C", "D")
'Set header_rng = Range(Cells(10, 2), Cells(10, UBound(myHeadings)))
Dim name As String
Dim name_Array As String
name = TixCollection(1).ADR
Call PrintArray(10, 2, myHeadings, name)
End sub
Sub PrintArray(RowPrint, ColPrint, ArrayName, WorkSheetName)
'Dim element As Variant
'For Each element In ArrayName
'Debug.Print element
'Next element
Sheets(WorkSheetName).Range(Cells(RowPrint, ColPrint), _
Cells(RowPrint, UBound(ArrayName))) = _
WorksheetFunction.Transpose(ArrayName)
End Sub
这有什么问题?