+ Reply to Thread
Results 1 to 6 of 6

find date in middle of numbers and use it to calculate a cell value

  1. #1
    Registered User
    Join Date
    10-12-2012
    Location
    Philadelphia, Pa
    MS-Off Ver
    Excel 2007
    Posts
    72

    find date in middle of numbers and use it to calculate a cell value

    I have a column that contains sample #. within the numbers is a date. Is there a way to have a macro find that date and subtract it from a different cell with a date and place the results in a new cell. I uploaded a sample worksheet to show you what I mean.


    In the first row I want it find 10-25-12 and subtract it from 10-31-12 and post the answer under the turnaround column. Is this possible?
    Attached Files Attached Files
    Last edited by CityInspector; 10-26-2012 at 11:16 AM.

  2. #2
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: find date in middle of numbers and use it to calculate a cell value

    hi CityInspector, option
    Attached Files Attached Files

  3. #3
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: find date in middle of numbers and use it to calculate a cell value

    Using your posted workbook,
    As long as the Col_B format is consistent, this regular formula subtracts the embedded date in B2 from the date in F2
    I2: =F2-MID(B2,4,8)

    Is that something you can work with?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  4. #4
    Registered User
    Join Date
    10-12-2012
    Location
    Philadelphia, Pa
    MS-Off Ver
    Excel 2007
    Posts
    72

    Re: find date in middle of numbers and use it to calculate a cell value

    I tried both options and both of the return a value of 1/6/1900.

    Ron- I copied your formula exactly and pasted in I2

    watersev- I copied your formula from the workbook you uploaded and pasted it in mine

  5. #5
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: find date in middle of numbers and use it to calculate a cell value

    Assuming you want the count of days...you'll need to change the number format for the formula cell from "date" to any of the appropriate number categories.

    For a quick fix, try this:
    • Select the formula cells
    • Hold down CTRL and SHIFT while you press 1....effectively pressing CTRL+!

    Does that help?

  6. #6
    Registered User
    Join Date
    10-12-2012
    Location
    Philadelphia, Pa
    MS-Off Ver
    Excel 2007
    Posts
    72

    Re: find date in middle of numbers and use it to calculate a cell value

    Ron- that worked. thanks for your help.

+ 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