+ Reply to Thread
Results 1 to 9 of 9

Finding maximum between dates with a suffixed number

  1. #1
    Forum Contributor
    Join Date
    08-24-2012
    Location
    Hollidaysburg, Pa
    MS-Off Ver
    Excel 2010
    Posts
    398

    Finding maximum between dates with a suffixed number

    I have some inputs in Column A that are in the format DATE_Package # . Date is in YYYY-MM-DD format.

    Example

    2016-10-24_Package 24
    2016-10-24_Package 25
    2016-10_31_Package 26
    2016-11-01_Package 27
    2016-11-01_Package 28

    All these values are in sequential order.

    I want my program to find the maximum of the above. Meaning = the most recent and message what my next pacakge number will be. So when macro button is clicked, it should pick todays's date and add suffix "Package 29" and thereby should read as 2016-11-02_Package 29

    Used a similar program for 3 years where the very same column was just numerical. Example, 1,2,3,4..... . So I used a code to find the Maximum and then add a count to it and messagebox the new one. Here is the code I used initially

    Please Login or Register  to view this content.
    I tried to use this

    Please Login or Register  to view this content.
    but it ends up giving the same value .

    So how do i improvise
    Please Login or Register  to view this content.
    in the the above code so that it just adds up the number

  2. #2
    Forum Contributor
    Join Date
    08-24-2012
    Location
    Hollidaysburg, Pa
    MS-Off Ver
    Excel 2010
    Posts
    398

    Re: Finding maximum between dates with a suffixed number

    I am trying to use
    Please Login or Register  to view this content.
    But with that it takes the last character only. But I would want it to consider all characters after the word "package" and the space. To make sure it works when the previous value is
    2016-11-01_Package 1001

  3. #3
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Finding maximum between dates with a suffixed number

    Let's start with this.

    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  4. #4
    Forum Contributor
    Join Date
    08-24-2012
    Location
    Hollidaysburg, Pa
    MS-Off Ver
    Excel 2010
    Posts
    398

    Re: Finding maximum between dates with a suffixed number

    can you explain your code?

    What does ReDim , UBound do ?

    How do I define the current region ?

    I copied your code and tried to run it but instead gave me an error. I am not so well versed with excel. Would appreciate it if you can explain it a bit.

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

    Re: Finding maximum between dates with a suffixed number

    Does this help?

    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    08-24-2012
    Location
    Hollidaysburg, Pa
    MS-Off Ver
    Excel 2010
    Posts
    398

    Re: Finding maximum between dates with a suffixed number

    Thanks for the help John. This is very much tied up to another thread of mine you just responded to.

    I modified my code to
    Please Login or Register  to view this content.
    and it works fine.

    However, I am going to try your approach shortly

    Thanks,

    Subbby

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

    Re: Finding maximum between dates with a suffixed number

    You're welcome. Hope you get it resolved.

  8. #8
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Finding maximum between dates with a suffixed number

    The only problem is that John's code won't work with package numbers larger then 999.
    Following does.

    Please Login or Register  to view this content.
    @ JOHN
    Thanks for giving good start.
    Last edited by bakerman2; 11-02-2016 at 02:13 PM.

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

    Re: Finding maximum between dates with a suffixed number

    @ bakerman2 - Oh Yeah, I didn't account for POST #2. Thanks for catching that and offering a reliable solution.

+ 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. Finding an adjacent value after finding a maximum value on another column
    By VanCricken in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-10-2016, 11:58 AM
  2. Replies: 7
    Last Post: 10-07-2015, 03:01 PM
  3. Replies: 2
    Last Post: 04-06-2012, 04:00 PM
  4. Replies: 3
    Last Post: 08-19-2011, 10:32 AM
  5. finding number of days between dates
    By gav_69 in forum Excel General
    Replies: 3
    Last Post: 03-14-2007, 07:19 AM
  6. Finding a maximum number...with an exception
    By cubsfan in forum Excel General
    Replies: 1
    Last Post: 04-07-2006, 01:50 PM
  7. Replies: 1
    Last Post: 07-08-2005, 04:05 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