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: 6
Default Strip date from string and transfer datetext to number

Hi NG,

I have a cell with date values in this string format
04Oct2004000000

I need to strip the date to another cell and made a macro that
uses:

ActiveCell.Formula =
"=VALUE(CONCATENATE(LEFT(RC[-4],2),""-"",MID(RC[-4],3,3),""-"",MID(RC[-4],6,
4)))"

to insert this formula
=VALUE(CONCATENATE(LEFT(M2;2);"-";MID(M2;3;3);"-";MID(M2;6;4)))
The macro then proceeds by copying the formula downwards for all rows.

The problem I have is that certain dates are not found. These strings will
generate the right date:
28Jun2004000000
05Jul2004000000
02Aug2004000000
06Sep2004000000

this one fails
04Oct2004000000
the error message in the cell in Excel is #VALUE!

Now I suspect that this is because I have danish language keyboard setup and
Excel is using danish month lists because of that.

Alternative to above approach would be to make a loop that inserts the date
for each row by reading the string value in column M and then via VBA return
the date to the cell in column Q, ie read 04Oct2004 and return 38264 as the
date value for 4-Oct-2004.

Something like

For each cell in InputRange
Read string value from cell
Transform string to date value using
Case
1: Jan
2: Feb
etc
Store value to variable

For each cell in OutputRange
Enter value of variable to cell
Next cell (in outputrange)

Next cell (in inputrange)

should do the trick. Any suggestion how I should do this is warmly welcome
as this a bit beyond my current skills.
Other solutions or suggestions are also welcome.

- Chr




 
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
Counting number of rows between date range and meeting 2 string criteria Hii Sing Chung Excel Worksheet Functions 11 July 21st 09 12:34 AM
Change 3 letter text string to a number string Pete Excel Discussion (Misc queries) 3 December 31st 07 07:47 PM
transfer date to number artisdepartis Excel Worksheet Functions 4 June 19th 07 09:30 AM
How can you strip the time of day out of a date field Ron Excel Discussion (Misc queries) 3 April 19th 06 07:25 PM
Date/Time - String or Number! RzB Excel Programming 4 October 27th 03 08:44 PM


All times are GMT +1. The time now is 11:46 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"