Get data into worksheet from User Defined Type

Richard Schollar

MrExcel MVP
Joined
Apr 19, 2005
Messages
23,707
Hi All

Given that I have the following UDT:

Code:
Type myString
   s1 As String * 100
   s2 As String * 100
   s3 As String * 100
   s4 As String * 100
   s5 As String * 100
End Type

What is the quickest way for me to enter each element into contiguous cells, eg Range("A1:A5")?

I could write:

Code:
Range("A1").Value = myString.s1
Range("A2").Value = myString.s2
'etc etc

But I think (hope) there is a much quicker all-in-one-go way of doing it.

Thanks for any replies.
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
This is what I came up with...

Code:
With myString
    Range("A1:A5") = Application.WorksheetFunction.Transpose(Array(.s1, .s2, .s3, .s4, .s5))
End With
 
Upvote 0

Forum statistics

Threads
1,214,819
Messages
6,121,739
Members
449,050
Latest member
excelknuckles

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top