+ Reply to Thread
Results 1 to 14 of 14

Finding all dates in a column that are in the range today to a week from now

  1. #1
    Registered User
    Join Date
    07-22-2008
    Location
    ctown
    Posts
    35

    Finding all dates in a column that are in the range today to a week from now

    Im trying to search a column (A), that has a list of dates (not in order), for the row in which the dates are equal to or greater than today and less than or equal to a week from today. I then want the information contained in the rows with these dates to be transferred to another sheet and ordered by date.
    Thanks, any help would be greatly appreaciated.
    Last edited by jrcream; 09-21-2008 at 10:56 PM.

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

    This macro checks column "A" on Sheet1 for the dates greater than or equal to today and less than or equal to 7 days from now. Those that pass the test have their entire row copied to Sheet2. You can change the sheet names in macro if you need to. They are marked in red.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  3. #3
    Registered User
    Join Date
    07-22-2008
    Location
    ctown
    Posts
    35
    I'm getting an error 400 everytime I try to run this macro.

    Also, how would i cut this code down so that the macro takes all the dates (not just today<=x=>+7), and copies the rows all the same then sorts them by date
    Last edited by jrcream; 09-22-2008 at 03:39 PM.

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

    The error "Application-defined or object-defined error" tells me what happened but not where. You will need to tell me where in the code you are encountering the error. I ran the code on my computer before posting it, and it worked with no problems.

    Sincerely,
    Leith Ross

  5. #5
    Registered User
    Join Date
    07-22-2008
    Location
    ctown
    Posts
    35
    I assigned the macro to a button. If that isn't contributing to the error then I'm not sure where the error lies since the code isn't highlighted in any place.

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

    Post your workbook and I take a look it. By the way, I am using Excel 2003.

    Sincerely,
    Leith Ross

  7. #7
    Registered User
    Join Date
    07-22-2008
    Location
    ctown
    Posts
    35
    Okay, I got the subscript error to go away, but only if the first row contains a date within the accepted range. Also, the macro only copies the information from the first row (& only if its within the accepted range) it does not check the other dates in column A and copy them if they're within the accepted range(today to today+7).
    I use excel 2003 and I am using your exact code.

  8. #8
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582
    FYI,

    I just tested Leith's code on Excel 2000 and it copied all rows with appropriate values to Sheet2. It worked fine with blank rows including row 1 and without.
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  9. #9
    Registered User
    Join Date
    07-22-2008
    Location
    ctown
    Posts
    35
    The code still only copies the first row in column A if its in the range, and if its not in th range I get an error 400.
    I am so confused the code does not work with empty rows and not at all like the above user described.
    Last edited by jrcream; 10-01-2008 at 02:16 AM.

  10. #10
    Registered User
    Join Date
    07-22-2008
    Location
    ctown
    Posts
    35
    here is my workbook for more clarification
    Attached Files Attached Files

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

    I found the problem. Here is the revised macro...
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  12. #12
    Registered User
    Join Date
    07-22-2008
    Location
    ctown
    Posts
    35
    I've been trying to change the range of dates searched to column E, but I'm having problems identifying the areas of code to be changed. Any help is greatly appreciated I'm still learning.

  13. #13
    Registered User
    Join Date
    07-22-2008
    Location
    ctown
    Posts
    35
    Is there a way to simply copy the values and text in the cells without copying their corresponding formulas, because the macro now works but all of the values are wrong

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

    Change this line in the macro...
    Please Login or Register  to view this content.
    To this if you only want the values to be copied...
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

+ 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. Macro for coding an action based on 3 columns of information
    By chozen86 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-31-2008, 10:44 PM
  2. Finding Dates in a range
    By Cullen8 in forum Excel General
    Replies: 5
    Last Post: 07-31-2008, 04:10 PM
  3. Replies: 1
    Last Post: 04-01-2008, 05:42 PM
  4. Massive Sorting question.
    By Rgaherty in forum Excel Programming / VBA / Macros
    Replies: 35
    Last Post: 11-07-2007, 02:15 PM
  5. Counting Dates and Finding Earliest
    By -emma- in forum Excel General
    Replies: 7
    Last Post: 07-24-2007, 05:03 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