View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Mbtch@. Mbtch@. is offline
external usenet poster
 
Posts: 1
Default Array loses data type when placed into range

I have a VB program that uses Automation to create a worksheet and
then dimension a range as large as an array Dim'ed in the VB
program... I then just set the range values equal to the array
variable... i.e. -

Set rngData = oExcel.Application.ActiveCell.Resize(UBound(arr, 1) + 1,
UBound(arr, 2) + 1)
rngData = arr

And it dumps the array into the range.

Problem: a text string from an array element like "0003334" is
interpreted as a number by excel when placed into the cell. the zeros
are considered "insignifigant" and they are removed, Just as if I had
typed the string into the cell myself.

I was thinking maybe concatenating a chr(39) to the front of the
string would cause excel to change the data type of the cell to a
string type, and left justify it in the cell, etc...

Is it o.k. to do this?