LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Separating text and dates.


Thanks for that Dave, pointed me in the right direction.

Had to make a slight change to the numbers - discovered that there was
an extra space at the end of the original cell data. Heres what I ended
up with in my macro:

' Fix Text and Date

' Insert 2 'Helper' columns

Columns("C:D").Select
Selection.Insert Shift:=xlToRight

cLastRow = Cells(Rows.Count, "A").End(xlUp).Row
For r = cLastRow To 1 Step -1

' Some rows don't have test/date so need to be sure not to work on
them

If InStr(1, Cells(r, "A"), "Starts:") < 1 Then
If InStr(1, Cells(r, "A"), "Performances") < 1 Then

' Set the cells need to do the job

Set a = Cells(r, "D") ' Target for date
Set b = Cells(r, "B") ' Cell containing text/date
Set c = Cells(r, "C") ' Target for text

' Get the date

a.Value = DateValue(Mid(Right(b, 11), 1, 3) & Mid(Right(b, 8), 1,
3) & Mid(Right(b, 5), 1, 4))

' Get the text

c.Value = Left(b, Len(b) - 12)

End If
End If
Next r

' Delete the original column, no longer needed

Columns("B:B").Select
Selection.Delete Shift:=xlLeft

Works like a charm. Another success on a good day of learning VBA.
Worked out how to use basic arrays, learnt about using offsets with
ranges and now this. Very happy.

Thanks again for the input.


--
Mark K
------------------------------------------------------------------------
Mark K's Profile: http://www.excelforum.com/member.php...o&userid=14117
View this thread: http://www.excelforum.com/showthread...hreadid=573763

 
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
How do I sum columns separating out the dates soconfused Excel Worksheet Functions 4 July 31st 09 03:50 PM
Separating dates from one column to Month, Date, Year columns frogstyle Excel Discussion (Misc queries) 2 August 6th 08 04:13 PM
Separating Text Té Excel Worksheet Functions 2 July 9th 08 11:58 PM
Separating text Francis Hookham Excel Discussion (Misc queries) 2 December 10th 06 08:35 PM
separating text dpdpdp Excel Worksheet Functions 2 July 12th 06 06:51 PM


All times are GMT +1. The time now is 06:32 AM.

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"