Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Setting Range = Array of User-Defined Types

I have a large array ['P()'] of Public Types ['PORecord'] from which I would
like to write some of the sub-types [eg. 'PO_OutputDate'] to a spreadsheet at
the end of a set of calculations. Currently I am using a "For...Next" loop,
but this is slooww.

Currently my Code goes something like this:

'Start Code
For q = UBound(P, 1) To LBound(P, 1)
Sheet1. Range(Info.PO_Output_Col & q).Value = P(q).PO_OutputDate
Next q
'End Code

What I would like to do is write all the OutputDates in the array at once to
a range rather than stepping through it bit by bit. This is what I had in
mind...

'start code
Sheet1.Range("Z:Z") = P().PO_OutputDate
'end code

.... however I get an "invalid qualifier" error. What am I doing wrong? How
can I fix this?

Thanks in advance,
Steve
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Setting Range = Array of User-Defined Types

Not tested but something like:

Dim i As Long
Dim nDate As Long
Dim DateArray() As Variant

nDate = UBound(P)
ReDim DateArray(nDate, 1)

For i = 1 To nDate
DateArray(i, 1) = P(i).PO_OutputDate
Next i

Range("Z1:Z" & nDate) = DateArray


"steve4446" wrote:

I have a large array ['P()'] of Public Types ['PORecord'] from which I would
like to write some of the sub-types [eg. 'PO_OutputDate'] to a spreadsheet at
the end of a set of calculations. Currently I am using a "For...Next" loop,
but this is slooww.

Currently my Code goes something like this:

'Start Code
For q = UBound(P, 1) To LBound(P, 1)
Sheet1. Range(Info.PO_Output_Col & q).Value = P(q).PO_OutputDate
Next q
'End Code

What I would like to do is write all the OutputDates in the array at once to
a range rather than stepping through it bit by bit. This is what I had in
mind...

'start code
Sheet1.Range("Z:Z") = P().PO_OutputDate
'end code

... however I get an "invalid qualifier" error. What am I doing wrong? How
can I fix this?

Thanks in advance,
Steve

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Setting Range = Array of User-Defined Types

Oh, BTW, I use Option Base 1 always so adjust your array dimensions
accordingly if you use zero-based arrays.

"steve4446" wrote:

I have a large array ['P()'] of Public Types ['PORecord'] from which I would
like to write some of the sub-types [eg. 'PO_OutputDate'] to a spreadsheet at
the end of a set of calculations. Currently I am using a "For...Next" loop,
but this is slooww.

Currently my Code goes something like this:

'Start Code
For q = UBound(P, 1) To LBound(P, 1)
Sheet1. Range(Info.PO_Output_Col & q).Value = P(q).PO_OutputDate
Next q
'End Code

What I would like to do is write all the OutputDates in the array at once to
a range rather than stepping through it bit by bit. This is what I had in
mind...

'start code
Sheet1.Range("Z:Z") = P().PO_OutputDate
'end code

... however I get an "invalid qualifier" error. What am I doing wrong? How
can I fix this?

Thanks in advance,
Steve

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
Reading values into an array of User Defined Types Susan[_6_] Excel Programming 6 December 12th 07 01:47 PM
Checking user defined types for Nothing jayklmno Excel Programming 5 May 3rd 06 09:21 PM
subs or functions with user defined types Ray Pixley Excel Programming 2 February 27th 06 03:25 AM
User-defined data type; Error: Only User-defined types... tiger_PRM Excel Programming 1 July 18th 04 03:32 PM


All times are GMT +1. The time now is 09:01 PM.

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

About Us

"It's about Microsoft Excel"