+ Reply to Thread
Results 1 to 15 of 15

find date string and paste into different column, same row

  1. #1
    Registered User
    Join Date
    10-31-2013
    Location
    Golden, CO
    MS-Off Ver
    Excel 2010
    Posts
    43

    find date string and paste into different column, same row

    I have a report where I would like to have a macro search for a date string in columns N-S and copy the date to Column C, same row. The number of rows will vary from day to day. I would then like to format all of Column C to 'mm/dd/yyyy'.

    Attached is a file where the date string is included in Column N on row 2 and Column O on the row 3. The dates for both these lines would need to be copied and pasted to their respective rows in Column C.

    Thanks in advance
    Ray
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: find date string and paste into different column, same row

    Maybe:

    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: find date string and paste into different column, same row

    Can we assume that each time there is date there the string "BY " and after some digits to remove?

  4. #4
    Registered User
    Join Date
    10-31-2013
    Location
    Golden, CO
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: find date string and paste into different column, same row

    PCI - Unfortunately no, the string 'BY' is not consistent across all rows and columns. Nothing about these fields is consistent. The only thing consistent about the date string are the hyphens '-'
    Last edited by rdowney79; 02-05-2014 at 05:16 PM.

  5. #5
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: find date string and paste into different column, same row

    How do you see there is a date in the cell
    Last edited by PCI; 02-05-2014 at 05:35 PM. Reason: Typo

  6. #6
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,946

    Re: find date string and paste into different column, same row

    A fvew questions.

    1. Does it have to be VBA, or will a formula do
    2. What are the different formats of the dates? Do they always usae "-" or are there some with "/" or "."?
    3. Will there be other instances, apart from the date, when "-" would be used?
    4. Could more than 1 of the cells have a date in them, how would you want that handled?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  7. #7
    Registered User
    Join Date
    10-31-2013
    Location
    Golden, CO
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: find date string and paste into different column, same row

    Quote Originally Posted by FDibbins View Post
    A few questions.

    1. Does it have to be VBA, or will a formula do
    I would prefer VBA, but as long as I can get a macro to do the work, Im down to try it.
    2. What are the different formats of the dates? Do they always usae "-" or are there some with "/" or "."?
    The date string will always use a hyphen -, as displayed in the attachment.
    3. Will there be other instances, apart from the date, when "-" would be used?
    No, only the date string will contain a hyphen, no other text in these columns will use a hyphen
    4. Could more than 1 of the cells have a date in them, how would you want that handled? No, the date and subsequent hyphens will only appear once in Columns N-S, however we could throw a simple error if so but its not necessary. Typically the date string will appear in Column N and the other columns are used for overspill, meaning if the string text doesnt all fit into column N, it will overspill into column O. If the string text doesnt fit into Column N and Column O, it will spill over to Column P and so on and so forth.
    I hope this helps

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: find date string and paste into different column, same row

    Hello rdowney79,

    This macro will adjust to the number of rows with data automatically. It will then look through columns "N:O" and extract any dates from the text. The extracted dates are then copied into column "C".
    Copy the code below and paste it into your "Moudle1".
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by Leith Ross; 02-05-2014 at 05:48 PM. Reason: Attached Workbook
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  9. #9
    Registered User
    Join Date
    10-31-2013
    Location
    Golden, CO
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: find date string and paste into different column, same row

    Leith, how do I update this code to only copy/paste the date if the value in column C is Null

  10. #10
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: find date string and paste into different column, same row

    Hello rdowney79,

    Will there ever be two dates in columns "N:O" of the same row?

  11. #11
    Registered User
    Join Date
    10-31-2013
    Location
    Golden, CO
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: find date string and paste into different column, same row

    Quote Originally Posted by Leith Ross View Post
    Hello rdowney79,

    Will there ever be two dates in columns "N:O" of the same row?
    There will always only be one date in columns N:O, actually we will want to look in columns N:S. But there will still always only be one date.

    Thanks,
    Ray

  12. #12
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,946

    Re: find date string and paste into different column, same row

    Try this regular formula, copied down in C...
    =IFERROR(DATEVALUE(MID(OFFSET(N2,0,MATCH("*"&"-"&"*",N2:S2,0)-1),SEARCH("-",OFFSET(N2,0,MATCH("*"&"-"&"*",N2:S2,0)-1),1)-2,8)),"")

  13. #13
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: find date string and paste into different column, same row

    Hello rdowney79,

    Here is the updated macro. The macro has been added to the attached workbook.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    10-31-2013
    Location
    Golden, CO
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: find date string and paste into different column, same row

    Problem Solved. Thank you Leith!

  15. #15
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: find date string and paste into different column, same row

    Hello rdowney79,

    You're welcome.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Find string and copy/paste contents to different column, same row
    By rdowney79 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 02-04-2014, 06:18 PM
  2. [SOLVED] Find string in column and paste corresponding row into other sheet
    By cronerd in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-28-2013, 01:21 AM
  3. [SOLVED] Find string in Column A then verify Date in Column B
    By Nu2Java in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 11-17-2012, 07:13 PM
  4. find date in column A and copy, paste and transpose valuse
    By myguess21 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-31-2012, 03:24 PM
  5. Replies: 8
    Last Post: 03-14-2006, 11:13 AM

Tags for this Thread

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