+ Reply to Thread
Results 1 to 10 of 10

Compare a date and identify which number it falls in based on date range.

  1. #1
    Registered User
    Join Date
    03-27-2016
    Location
    United States
    MS-Off Ver
    2010
    Posts
    39

    Compare a date and identify which number it falls in based on date range.

    Hi,
    I have a workbook, with two sheets - sheet 1, sheet 2.

    Sheet 1 has headers - Account, Date
    Sheet 2 has headers - Account, Period, Date 1, Date 2. Date 1 is start date, date 2 is end date.

    What I am trying to achieve is for excel macro or formulas to update sheet 1 with period from sheet 2, based on the date lited in sheet 1.

    For example: first entry in sheet 1, account 1 has date 06/22/2016. In sheet 2, this account 1 has various dates with period number attached to it. For this particular entry in sheet 1, I want to see 1 as an answer in column C because 06/22/2016 falls between the date range 12/1/2015 - 11/30/2016, which is period 1 in sheet 2. Similarly, row 65 in sheet 1 says "2" because 12/2/2016 falls in between 12/01/2016 thru 11/30/2017 in sheet 2.

    Notes:
    - Sheet 1 and Sheet 2 will have multiple lines with same dates. I have 20 more columns explaining what happened on that particular date.
    - I will have 100's of accounts in both sheets.


    Attached is a sample. Thank you for looking into this.
    Your help is appreciated.
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Compare a date and identify which number it falls in based on date range.

    Hello maryflower. Sheet2 has 27 rows of data of which 24 rows are repeats.
    By removing those 24 you are left with only 3 useful rows. In your real workbook: Can those 24 rows be deleted?...

    In Sheet1 something similar occurs: 1183 rows could be deleted.

    Comments?...
    You are always very welcome if you add reputation by clicking the * (bottom left) of each message that has helped you.

  3. #3
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Compare a date and identify which number it falls in based on date range.

    And another question: Only 'Account 1' are you analyzing?...

    If not, you should upload a more real example to the Forum.

  4. #4
    Registered User
    Join Date
    03-27-2016
    Location
    United States
    MS-Off Ver
    2010
    Posts
    39

    Re: Compare a date and identify which number it falls in based on date range.

    Thank you for the response, and helping.
    I can delete duplicates in sheet 2 but not in sheet 1 since I have different $ posted to each date. In reality, I will have more accounts. Attaching updated file with 2 accounts.

    All I am trying to do is identify period in sheet 1 for each date based on date ranges in sheet 2.
    Attached Files Attached Files

  5. #5
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Compare a date and identify which number it falls in based on date range.

    I think this can help you:

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by beyond Excel; 01-24-2023 at 04:23 PM.

  6. #6
    Registered User
    Join Date
    03-27-2016
    Location
    United States
    MS-Off Ver
    2010
    Posts
    39

    Re: Compare a date and identify which number it falls in based on date range.

    Thank you . I will definitely try this.
    I was also able to achieve this by using Lookup formula. It made my file heavy sized

    Macro might be a way but I am going to try. Will revert
    Last edited by maryflower; 01-24-2023 at 05:05 PM.

  7. #7
    Registered User
    Join Date
    03-27-2016
    Location
    United States
    MS-Off Ver
    2010
    Posts
    39

    Re: Compare a date and identify which number it falls in based on date range.

    If I have to change column reference in sheet 1, which part of the macro should I change? In reality, my account is col B (col 2), date is column F (col 6), result is column AJ (col 36)

  8. #8
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Compare a date and identify which number it falls in based on date range.

    .
    Then try this new version:
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    03-27-2016
    Location
    United States
    MS-Off Ver
    2010
    Posts
    39

    Re: Compare a date and identify which number it falls in based on date range.

    This is magical! thank you so much

  10. #10
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Compare a date and identify which number it falls in based on date range.

    Quote Originally Posted by maryflower View Post
    This is magical! thank you so much
    Jajaja... "magical"

    Please, Maryflower, don't forget to click on the * below and to the left of post #8...

+ 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] identify which week a specified date falls in
    By Ricky Wilko in forum Excel Formulas & Functions
    Replies: 19
    Last Post: 08-24-2022, 11:12 AM
  2. [SOLVED] Identify if date falls within a date range
    By Chris F in forum Excel - New Users/Basics
    Replies: 14
    Last Post: 02-23-2022, 08:40 AM
  3. Return a number if a date falls between range of two dates
    By zmanzander in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-03-2020, 02:46 PM
  4. Compare date range to list of ranges and identify gaps
    By James Keuning in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-13-2019, 12:05 AM
  5. [SOLVED] IF/Then Formula to add to a date depending if a number falls w/in a certain range
    By RMFM55 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-06-2019, 09:59 AM
  6. [SOLVED] Formula that pulls across a value based on the which date range the given date falls into.
    By h2holbro22 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 09-30-2018, 04:30 PM
  7. Replies: 15
    Last Post: 04-08-2013, 12:40 PM

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