LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default How convert a cell subtype? (from vbDouble to vbString)

Yeah you're right.. I didn't show but I then used a statement of
cells(1,7)=newvar after the and the cell still didn't change from sub-type 5
to sub-type 8. I thought maybe I had to clear out whatever was in cells(1,7)
first and that's why I did the cells(1,7).clear and then copied the newvar
(which is actually sub-type 8) into cells(1,7). But 1,7 is still type 5 not
8 as I wanted. I know I'm doing something fundamentally wrong.

If VarType(Cells(1, 7)) = 5 Then
newvar = CStr(Cells(1, 7))
Cells(1, 7).Clear
cells(1,7)=newvar
End If
--
Chet Shannon


"Rowan Drummond" wrote:

Are you sure you get vartype 5 on the second test. I would expect
vartype 0 (empty) as your code is clearing the cell.

You are setting newvar to be a string so if you tested that you would
get a vartype of 8. All you are doing to the cell is deleting the
contents and formatting. I don't see how you would expect it to have a
string variable type.

Hope this helps
Rowan

Chet Shannon wrote:
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


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How convert a cell subtype? (from vbDouble to vbString) Chet Shannon[_4_] Excel Programming 0 December 13th 05 04:52 AM
How convert a cell subtype? (from vbDouble to vbString) Rowan Drummond[_3_] Excel Programming 0 December 13th 05 04:51 AM
How convert a cell subtype? (from vbDouble to vbString) JE McGimpsey Excel Programming 0 December 13th 05 04:39 AM
How convert a cell subtype? (from vbDouble to vbString) Rowan Drummond[_3_] Excel Programming 0 December 13th 05 04:25 AM
How convert a cell subtype? (from vbDouble to vbString) Chet Shannon[_4_] Excel Programming 0 December 13th 05 04:11 AM


All times are GMT +1. The time now is 10:18 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"