VBA Code for type casting arrays

Vaslo

Board Regular
Joined
Jun 3, 2009
Messages
159
Hello,

I have an array that I am unpivoting data for entry in Power Pivot. For some of the rows, I can merely copy and paste the row quickly using a range. I use the code to transfer the array to two columns in the final sheet.

Data = wsCalc.Range("E6:F2000").Value
wsNew.Range("D2:E" & RowLen + 1).Value = Data

The problem is - when I copy, because it is a number, Excel seems to want to paste as a number (it is really a unique indentifier). Probably a simple issue but I want it to be output as text. I tried to put CStr around the first line (wsCalc.Range("E6:F2000").Value) but that crashes Excel. Is there a way so that the final data that hits the sheet is text?

Thanks!
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Format the destination range as Text before you put the data from the array in it.
 
Upvote 0

Forum statistics

Threads
1,215,281
Messages
6,124,045
Members
449,139
Latest member
sramesh1024

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