One Shot Array

jaybee3

Active Member
Joined
Jun 28, 2010
Messages
307
Hey again folks,

Having a bit of an issue with an array (MyResult). Each "line", as it were, has five "columns", formatted differently (got some doubles and some strings). When I write the array using:

Code:
.Range(.Cells(1, 1), .Cells(UBound(MyResult), UBound(MyCodes))).Value = MyResult

Some of the string elements are converted to numbers. For example: MyResult(6,4) is "0718875" and this appears as "718875" on the sheet.

Any ideas?
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
For 1-dimensional array:
Code:
.Cells(1, 1).Resize(UBound(MyResult)) = MyResult

For 2-dimensional array:
Code:
.Cells(1, 1).Resize(UBound(MyResult,1), UBound(MyResult, 2)) = MyResult
 
Upvote 0
Have you tried formatting the cells appropriately before transferring your array?

Yes it works if I format the cells before writing. However previously when I looped through the array writing the results individually, I didn't need to format the cells.
 
Upvote 0

Forum statistics

Threads
1,216,099
Messages
6,128,822
Members
449,470
Latest member
Subhash Chand

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