How do you change the data type of a cell using VBA?

J

justme0010

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.
 
D

Dave Peterson

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top