Printing VBA variable values to Excel 
Author Message
 Printing VBA variable values to Excel

Hi guys

Any help with this problem would be greatly appreciated.

I've created a 'variable tree' using nested user-defined types. So, for
example, I have variables of the form: size.large.width and
size.large.height where 'size' and 'large' are user-defined types
and 'width' and 'height' are, say, integer types.

Is it possible to print all the variable values to an Excel sheet
without having to loop explicitly over all the variables in the top-
level container variable ('size' in my example). This would make my
code much more robust (in case I edit the list of variables at a lower
level in the tree) and a lot shorter (in my real program, there
are hundreds of variables contained in each top-level container
variable).

I guess this problem could be solved by referencing the variables using
something like: size.large.item(2) instead of size.large.height.

Getting the values into Excel is not the problem, its obtaining a
dynamic list of those variables that I cannot currently do.

Thanks in advance

Dave Ellis

Sent via Deja.com
http://www.*-*-*.com/



Thu, 26 Jun 2003 19:44:50 GMT  
 Printing VBA variable values to Excel
Ok - I've been looking at my problem further and I think all I need
to know is this:

Is there a workaround for using the For Each... Next statement with an
array of user-defined types?

The Excel VBA Help file suggests using the Array function - but surely
this would involve me explicitly listing my variable names in the code
('height' and 'width' in my example in my previous post), which is what
I want to avoid in the first place!

Any ideas, guys and gals?

David Ellis

Sent via Deja.com
http://www.deja.com/



Thu, 26 Jun 2003 23:05:26 GMT  
 Printing VBA variable values to Excel
Once the code is compiled, the names you used for the elements of the UDT
don't exist any more. They are replaced by offsets from the beginning of the
UDT's memory space. So, AFAIK, if you want to list variable names, you'll have
to do the listing.
Quote:

>Ok - I've been looking at my problem further and I think all I need
>to know is this:

>Is there a workaround for using the For Each... Next statement with an
>array of user-defined types?

>The Excel VBA Help file suggests using the Array function - but surely
>this would involve me explicitly listing my variable names in the code
>('height' and 'width' in my example in my previous post), which is what
>I want to avoid in the first place!

>Any ideas, guys and gals?

>David Ellis

>Sent via Deja.com
>http://www.deja.com/



Fri, 27 Jun 2003 02:23:48 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Excel VBA Relative Value Variable

2. Writing VBA Variable values back to Excel Spreadsheet

3. Printing variable print ranges Excel 2000

4. Partial cell value assigned to variable in VBA?

5. VBA Average Range Value to Variable?

6. Set VBA variable to cell value

7. Keeping values in variables between runs of VBA

8. Setting form control value to a variable in VBA

9. assign VBA variable value to Textbox within Form

10. Displaying values of VBA Variables on forms


 
Powered by phpBB® Forum Software © phpBB Group