Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 175
Default ReDim Variant array for worksheet copy

I am trying to create a variant array from multiple data sources then plop
that array into a worksheet.
Dim vaCounts() as Variant
ReDim vaCounts(1 To 1, 1 To 3) As Variant
For lRow = 1 To UBound(vaPOData, 1)
If vaPOData(lRow, 7) sLastSite Then
' process row that starts a site group
iSiteCount = iSiteCount + 1
If iSiteCount 1 Then ReDim Preserve vaCounts(iSiteCount, 3) As
Variant

I get subscript outof range when iSiteCount = 2
I dont understand why a ReDim would fail, the help says a ReDim can resize
the array as many times as you wish.
Is there a better way to create a variant array that will allow writing to a
worksheet?

If i knew I had 100 sites I could run this:
Dim vaCounts() as Variant
vaCounts = Range("A1:C100").value
.... make any changes to vaCounts row by row...
Range("A1:C100").value = vaCounts

How do I do this with out knowing that I need 100 rows to start with?

--
Regards,
John
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default ReDim Variant array for worksheet copy

You can only ReDim the last dimension of an array.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"John Keith" wrote in
message
...
I am trying to create a variant array from multiple data sources
then plop
that array into a worksheet.
Dim vaCounts() as Variant
ReDim vaCounts(1 To 1, 1 To 3) As Variant
For lRow = 1 To UBound(vaPOData, 1)
If vaPOData(lRow, 7) sLastSite Then
' process row that starts a site group
iSiteCount = iSiteCount + 1
If iSiteCount 1 Then ReDim Preserve
vaCounts(iSiteCount, 3) As
Variant

I get subscript outof range when iSiteCount = 2
I dont understand why a ReDim would fail, the help says a ReDim
can resize
the array as many times as you wish.
Is there a better way to create a variant array that will allow
writing to a
worksheet?

If i knew I had 100 sites I could run this:
Dim vaCounts() as Variant
vaCounts = Range("A1:C100").value
... make any changes to vaCounts row by row...
Range("A1:C100").value = vaCounts

How do I do this with out knowing that I need 100 rows to start
with?

--
Regards,
John



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copying a Variant Array to a worksheet John Keith[_2_] Excel Programming 2 November 3rd 05 10:30 PM
how to redim the type of variant element lvcha.gouqizi Excel Programming 5 October 25th 05 07:05 PM
ReDim Object array as parameter of Variant array Peter T Excel Programming 4 May 10th 05 02:11 PM
Dim / Redim of an Array Fred[_17_] Excel Programming 4 June 28th 04 03:16 PM
ReDim an Array Art[_5_] Excel Programming 3 October 25th 03 03:30 PM


All times are GMT +1. The time now is 11:17 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"