ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How convert a cell subtype? (from vbDouble to vbString) (https://www.excelbanter.com/excel-programming/347964-how-convert-cell-subtype-vbdouble-vbstring.html)

Chet Shannon[_4_]

How convert a cell subtype? (from vbDouble to vbString)
 
I am trying to convert a cell from sub-type 5 to sub-type 8. (Which is to say
from 'vbdouble' to 'vbstring'.) But when I apply the cstr (convert to
string) function the cell itself won't change sub-types as I want. Any ideas
how to change the sub-type value of a cell?

Here is the code I am using to convert the cell sub-type.
If VarType(Cells(1, 7)) = 5 Then
newvar = CStr(Cells(1, 7))
Cells(1, 7).Clear
End If
But when I then try test the value of the cell I've just changed by issuing
the command vartype(cells(1,7)) the value sub-type still shows up as 5 and
not 8 as it should be for a string. What am I doing wrong? I have the sense
that it has some thing to do with cstr working on variables but not on cells
maybe?

Thanks,
Chet


All times are GMT +1. The time now is 04:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com