View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Writing an array(2d) of user types to a worksheet

Putting multiple values in each element of your 2d-array as you do with your
UDT would mean that you would not be able to write it to a worksheet in any
other way than looping through and writing each value. You might write it
to another expanded 2D array first, then write that to the worksheet in one
step.

--
Regards,
Tom Ogilvy


"John Keith" wrote in message
...
What is the "fast" way to write out a 2d-array of user defined types to a
worksheet.

I.E.
User type is a record of 10 fields. Which has 30 rows...

Type UT
field1 as string
field2 as string ....
field10 as string
end type
Dim myUDTarray () as UT
...
ReDim Preserve myUDTarray(ubound(myUDTarray) + 1) 'adds a row
myUDTarray(ubound(myUDTArray)).field1 = "v1"
...
myUDTarray(ubound(myUDTArray)).field10 = "v10"

Using the set rng = range("a1").cells
then copying myUDTarray(x).each field...to the rng.offset(x,y).value in a
loop is extremely slow.

what are some other options?

When I try to write code that uses variant arrays I get a comple error

that
says my user type must be in a public module... but I do not want the type
"public" it is used ONLY in this one module.. however... what is the
statement that I would put at the top of the module to allow me to assign

the
usertype'd array to a worksheet range.

If there is some way to build a valid variant array from my user type,
perhaps that would work.

Ideas?


--
Regards,
John