vbscript 将RecordSet列写入范围

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vbscript 将RecordSet列写入范围相关的知识,希望对你有一定的参考价值。

Sub WriteRecordSetColumnToRange(ByVal adoRecSet As ADODB.Recordset, ByVal columnName As String, ByVal startCell As Range)
'Description:   Writes one field(column) of a Recordset to a Range
'Input:         Recordset object; ; name of the field(column); start cell (Range)
'Dependency:    CopyRecordsetColumnToArray 

'******   DEKLARÁCIÓK   ********************
Dim tempArr     As Variant
Dim tempRng     As Range
'*******************************************

'   if startCell consists of more then one cell then upper-left cell is used
    If startCell.Cells.Count > 1 Then startCell = startCell.Cells(1)
    
'   Save column to Array
    tempArr = CopyRecordsetColumnToArray(adoRecSet, columnName)
    
'   Resize Range then write Array to Range
    Set tempRng = startCell.Resize(UBound(tempArr, 1) + 1, 1)
    tempRng.Value = tempArr
        

End Sub

以上是关于vbscript 将RecordSet列写入范围的主要内容,如果未能解决你的问题,请参考以下文章

vbscript 将Recordset复制到数组

vbscript 将ADO Recordset复制到2D阵列

vbscript 将记录集写入范围

vbscript 将字段信息写入范围

vbscript 将记录集写入范围

vbscript 将标题写入范围