+ Reply to Thread
Results 1 to 12 of 12

Extract date from string

  1. #1
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Extract date from string

    I have this string........actually its the contents of a cell..........I want to extract the date part of this string and then save it back onto itself.

    i am enclosing a file with the example strings.
    Attached Files Attached Files

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,531

    Re: Extract date from string

    Maybe:

    Please Login or Register  to view this content.

    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: Extract date from string

    exactly what i was looking for.....thanks.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,531

    Re: Extract date from string

    You're welcome. Thanks for the rep.

  5. #5
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: Extract date from string

    Here is the code i ended up with. I combined code from several different threads i have posted...........i keep learning about how to more efficiently do things........this code is cool because it puts values into array efficiently and then extracts them from the array very efficiently.

    Please Login or Register  to view this content.


    Just thought i would share.

  6. #6
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: Extract date from string

    one question i did have about the array that someone might answer is.........why is the array two dimensional........not sure why the creator of the code did it this way but it works.

  7. #7
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Extract date from string

    Interested in efficiency ?

    Please Login or Register  to view this content.



  8. #8
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: Extract date from string

    ok, that is just too cool. but what about if the number of rows in col A is variable and could be more than 100?

    very cool !

  9. #9
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Extract date from string

    Either you take a safe range:

    Please Login or Register  to view this content.
    or you use a dynamically named range:

    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: Extract date from string

    thanks! Had a few questions.

    1) What is c00?

    2) what is this doing exactly?

    Please Login or Register  to view this content.

  11. #11
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Extract date from string

    "c00" is a text string; any string would do as long as you use it in the next line in the places where c00 is now.

    second question: that line makes a named range of all the cells in column A that contain values. The name of that range is "c00" in this example.

  12. #12
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,260

    Re: Extract date from string

    Quote Originally Posted by welchs101 View Post
    one question i did have about the array that someone might answer is.........why is the array two dimensional........not sure why the creator of the code did it this way but it works.
    If you assign a range to a Variant, you always get a 2D array, even if the range is only one row or column.
    Remember what the dormouse said
    Feed your head

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1