VBA Change Cell Text

satkin2

New Member
Joined
Oct 22, 2009
Messages
25
Hi,

I've got a spreadsheet that has a row of dates in the format _31May2011 _30Jun2011 _31Jul2011 etc;
I'm going to link into these dates in a chart, so want to remove the _ so as that I can use them as dates, currently they are treated as text.

How can I change the cell value to remove the _ and set the new field to be in date format?

Many thanks
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Use Find and Replace

In the replace add the _ then click replace all
 
Upvote 0
Is _31May2011 _30Jun2011 _31Jul2011 in one cell?
 
Upvote 0
Is _31May2011 _30Jun2011 _31Jul2011 in one cell?

No, sorry I should have made myself clearer, each month is a column, ie: Col B = _31May2011, Col C = _30Jul2011.


Use Find and Replace

In the replace add the _ then click replace all

This gets rid of the _ but what is left ie: 31May2011 is in General format, and it is treated as a string, not a date field. I'd like to make it a date field too.
 
Upvote 0
So, what prevents you from setting format as Date?
 
Upvote 0
So, what prevents you from setting format as Date?

So I've done the find and replace and the field is now 31May2011, but when I click on the cell it shows '31May2011, making it a text string. Going to Format and setting as date doesn't set it to date, it remains as a General, because it's a text string.

I've subsequently tried running a find and replace, replacing the ' with nothing, but this didn't work either.
 
Upvote 0
' makes Excel treat content as text. Before removing "_", make cell's format as Date.
 
Upvote 0
' makes Excel treat content as text. Before removing "_", make cell's format as Date.

I tried that, but it still doesn't work. I did the following...
  • Set format as date
  • Find and replace _ with <blank>
  • Checked format, it still shows as Date
  • Checked cell value it still has '31May2011 so still treats as string.
 
Upvote 0
And do u have spaces like "31 May 2011"?
 
Upvote 0

Forum statistics

Threads
1,224,516
Messages
6,179,231
Members
452,898
Latest member
Capolavoro009

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top