Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 1
Default How do you change the data type of a cell using VBA?


For instance, with VBA I am trying to place "February 2007" in a cell
but it keeps showing up as Feb-07. I want it to show up as literal
text.




--
justme0010
  #2   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 11,058
Default How do you change the data type of a cell using VBA?

Sub text_it()
Range("A1").Value = Chr(39) & "February 2007"
End Sub

--
Gary''s Student - gsnu2007c
  #3   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 35,218
Default How do you change the data type of a cell using VBA?

You could keep the value a date and just format the cell the way you like:

with activecell
.numberformat = "mmmm yyyy"
.value = dateserial(2007,2,1)
end with

You could also format the cell as text first:

with activecell
.numberformat = "@" 'text
.value = "February 2007"
end with

or this variation of Gary's Student's response:

with activecell
.numberformat = "General"
.value = "'February 2007"
end with



justme0010 wrote:

For instance, with VBA I am trying to place "February 2007" in a cell
but it keeps showing up as Feb-07. I want it to show up as literal
text.

--
justme0010


--

Dave Peterson
Reply
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
Change chart type in single data series, Excel 2007 momof3 Charts and Charting in Excel 3 June 30th 07 02:45 PM
Type data in one cell - and it automatically populates another cel Tom Excel Worksheet Functions 5 March 18th 07 04:21 AM
How do I type in colour without having to change it every cell Jumiclads Excel Discussion (Misc queries) 2 March 15th 07 04:48 PM
how to change all the words of one type(Gunsuh type)to another metumevlut Excel Discussion (Misc queries) 2 November 11th 05 03:29 PM
Change Excel cell format date type examples ("14-Mar-01") Cogito.ergo.sum Setting up and Configuration of Excel 1 May 17th 05 06:13 PM


All times are GMT +1. The time now is 06:52 PM.

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

About Us

"It's about Microsoft Excel"