ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Fill a Range with VB SafeArray (https://www.excelbanter.com/excel-programming/294640-fill-range-vbulletin-safearray.html)

Rob[_17_]

Fill a Range with VB SafeArray
 
Is there a fast way to fill a range of cells with the contents
of a VB SafeArray. I need a shortcut to the following
code :

For i = 0 To UBound(c)
Sheets(sSheet).Cells(i + 2, 6).Value = A(i)
Next i

Also, is there a fast way to fill VB SafeArray with the
contents of a Range. Again, I need a shortcut to the
following code :

ReDim FVE(0 To cds.cbData)
For i = 0 To cds.cbData
FVE(i) = Sheets(sSheet).Cells(i + 2, 20).Value
Next i

Please help and TIA, Robert



Bob Phillips[_6_]

Fill a Range with VB SafeArray
 
Hi Rob,

What is wrong with the loop? It's fast, what more do you need?

The latter can be done with

ReDim FVE(0 To cds.cbData)
FVE = Sheets(sSheet).Cells(2, 20).Resize(cds.cbData+1)

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Rob" wrote in message
...
Is there a fast way to fill a range of cells with the contents
of a VB SafeArray. I need a shortcut to the following
code :

For i = 0 To UBound(c)
Sheets(sSheet).Cells(i + 2, 6).Value = A(i)
Next i

Also, is there a fast way to fill VB SafeArray with the
contents of a Range. Again, I need a shortcut to the
following code :

ReDim FVE(0 To cds.cbData)
For i = 0 To cds.cbData
FVE(i) = Sheets(sSheet).Cells(i + 2, 20).Value
Next i

Please help and TIA, Robert





Rob[_17_]

Fill a Range with VB SafeArray
 
Nothing, I was hoping for something more concise. And you gave me what I
asked for. Thank you

"Bob Phillips" wrote in message
...
Hi Rob,

What is wrong with the loop? It's fast, what more do you need?

The latter can be done with

ReDim FVE(0 To cds.cbData)
FVE = Sheets(sSheet).Cells(2, 20).Resize(cds.cbData+1)

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Rob" wrote in message
...
Is there a fast way to fill a range of cells with the contents
of a VB SafeArray. I need a shortcut to the following
code :

For i = 0 To UBound(c)
Sheets(sSheet).Cells(i + 2, 6).Value = A(i)
Next i

Also, is there a fast way to fill VB SafeArray with the
contents of a Range. Again, I need a shortcut to the
following code :

ReDim FVE(0 To cds.cbData)
For i = 0 To cds.cbData
FVE(i) = Sheets(sSheet).Cells(i + 2, 20).Value
Next i

Please help and TIA, Robert







Bob Phillips[_6_]

Fill a Range with VB SafeArray
 
Sorry I couldn't provide one for the former.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Rob" wrote in message
...
Nothing, I was hoping for something more concise. And you gave me what I
asked for. Thank you

"Bob Phillips" wrote in message
...
Hi Rob,

What is wrong with the loop? It's fast, what more do you need?

The latter can be done with

ReDim FVE(0 To cds.cbData)
FVE = Sheets(sSheet).Cells(2, 20).Resize(cds.cbData+1)

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Rob" wrote in message
...
Is there a fast way to fill a range of cells with the contents
of a VB SafeArray. I need a shortcut to the following
code :

For i = 0 To UBound(c)
Sheets(sSheet).Cells(i + 2, 6).Value = A(i)
Next i

Also, is there a fast way to fill VB SafeArray with the
contents of a Range. Again, I need a shortcut to the
following code :

ReDim FVE(0 To cds.cbData)
For i = 0 To cds.cbData
FVE(i) = Sheets(sSheet).Cells(i + 2, 20).Value
Next i

Please help and TIA, Robert










All times are GMT +1. The time now is 01:36 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com