View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
John Keith[_2_] John Keith[_2_] is offline
external usenet poster
 
Posts: 175
Default Writing an array(2d) of user types to a worksheet

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