LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Separating parts of a string in VBA

Actually, there is a problem with ozgrid's first formula... it will return
the wrong date (year part) if the date is in November or December after the
9th of the either of those months. Since the text part of your cell values
are fixed and constant, and since the year part of your dates are always
2-digits long, you can use these formulas to retrieve the dates....

=--MID(A1,6, FIND(" ",A1,7)-6)

=--MID(A1,FIND("THRU",A1)+5,8)

By the way, your Subject line said you were after a VBA solution, so I did
not think to give you a formula solution originally.

--
Rick (MVP - Excel)



"Andrew" wrote in message
...
On Mar 31, 6:03 pm, "ozgrid.com" wrote:
In B1 (format as date) and copied down;
=--TRIM(MID(A1,FIND(" ",A1),8))
In C1 (format as date) and copied down;
=--TRIM(MID(A1,FIND("THRU",A1)+5,256))

In VBA replace FIND for Instr function.

I would use EditReplace and replace "DATE" with nothing and "THRU" with
nothing then use Text to columns to split the 2 dates.

--
Regards
Dave Hawleywww.ozgrid.com

"Andrew" wrote in message

...

Hello,
I have a string in cells(1,1). The value of the cell is "DATE" 1/1/10
THRU 3/1/10" I want to separate this string into the two new strings
such that one string would read "1/10/10" and the other would read
"3/1/10". In C programming, this would be fairly easy. But in VBA I
don't know any string functions which can read and compare individual
characters. Does anyone know how to accomplish what I am trying to
do?


thanks


Thanks. Both of these work fine.




 
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
formula for separating parts of cells Jamie Excel Worksheet Functions 18 September 9th 09 03:10 PM
splitting string in 2 parts ashishprem[_4_] Excel Programming 2 February 14th 06 01:30 PM
Extract certain parts of string djDaemon Excel Worksheet Functions 3 February 2nd 06 07:42 PM
Extract certain parts of string djDaemon Excel Worksheet Functions 0 February 2nd 06 03:31 PM
Separating a string to two fields asdf032 Excel Programming 3 September 8th 05 06:57 PM


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