reformat date issue

englishrob

New Member
Joined
May 17, 2010
Messages
22
I’m on Excel 2010<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
<o:p> </o:p>
This is a piece of code designed to reformat date from US to <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /><st1:country-region w:st="on"><st1:place w:st="on">UK</st1:place></st1:country-region> (i.e. mm/dd/ccyy to dd/mm/ccyy) based on cells selected by the user. <o:p></o:p>
<o:p> </o:p>
Although the string variable shows the reformat correctly, when I place the value in the cell it reverts to type.<o:p></o:p>
<o:p> </o:p>
Anybody got any ideas?<o:p></o:p>
<o:p> </o:p>
Set rSel = Selection<o:p></o:p>
<o:p> </o:p>
For Each rCel In rSel<o:p></o:p>
<o:p></o:p>
sMyText = rCel.Text<o:p></o:p>
<o:p></o:p>
wk2.Range("G" & rCel.Row).Value = Mid(sMyText, 4, 3) & Mid(sMyText, 1, 3) & Mid(sMyText, 7, 4)<o:p></o:p>
<o:p></o:p>
<o:p></o:p>
Next rCel


thanks in advance<o:p></o:p>
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
It's a string you are putting back, try putting back a 'real' date value.
Rich (BB code):
wk2.Range("G" & rCel.Row).Value = DateValue(Mid(sMyText, 4, 3) & Mid(sMyText, 1, 3) & Mid(sMyText, 7, 4))

By the way, did you try just formatting the dates?
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,831
Members
452,946
Latest member
JoseDavid

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