View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Paul Paul is offline
external usenet poster
 
Posts: 6
Default String to Variant conversion

"Paul" wrote:
I am using Harlan Grove's PULL function to grab data from other
spreadsheets, and it mostly works except that some strings that look
like dates get converted to numbers and therefore don't work with
VLOOKUP and the like. For example, "06-6107" gets changed to
1536728. It seems that this is happening in this bit of code:


For Each c In r
c.Value = xlapp.ExecuteExcel4Macro(b & c.Address(1, 1, xlR1C1))
Next c


The Value property is a Variant, so in the conversion the string is
interpreted as a date. Is there any way to force that to be converted
a Variant/String instead of Variant/Double?



On Oct 3, 6:08 pm, Joel wrote:
Read the value into a string before wrting to the cell

Dim TempString as string
For Each c In r
TempString = xlapp.ExecuteExcel4Macro(b & c.Address(1, 1, xlR1C1))
c.value = TempString
Next c


Thanks for the suggestion! That was the first thing I tried, and it
didn't work. When the string variable was assigned to c.value, did
the same thing as the direct assignment did before.