+ Reply to Thread
Results 1 to 6 of 6

VBA Date Comparison, and then some...

  1. #1
    Registered User
    Join Date
    08-08-2013
    Location
    Baltimore, MD
    MS-Off Ver
    Excel 2010
    Posts
    15

    VBA Date Comparison, and then some...

    I have a list of accounts with established dates in column B. I'm using a form to create a report. The report should show only accounts with an established date after October 1 of the year selected in a combo box in the form. I was thinking of using a Do...Loop to look at each row, compare the established date to October 1 of the year chosen, and clear the rows where the date is less than the 10/1 of the chosen year. I think I was doing good until it came time to compare the date to 10/1 of the chosen year.

    Here is what I have, but it isn't working, can anyone help?


    Please Login or Register  to view this content.
    Last edited by Jubb; 07-26-2017 at 01:35 PM.

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: VBA Date Comparison, and then some...

    Deleted, OP added code tags as requested.
    Last edited by Arkadi; 07-26-2017 at 01:36 PM.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: VBA Date Comparison, and then some...

    Can you provide more of the code? And a better description of "not working"? Do you get an error?

  4. #4
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: VBA Date Comparison, and then some...

    Here is a possibility...

    Please Login or Register  to view this content.
    Note that if you want to delete the rows instead of just clearing them, you'd have to go from bottom to top, meaning the loop would change to
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    08-08-2013
    Location
    Baltimore, MD
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: VBA Date Comparison, and then some...

    I don't know how much of the code you want, so here's a little more, let me know if that's what you need to see or if you need more.

    Please Login or Register  to view this content.
    There is no error, but none of the rows are being cleared.

  6. #6
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: VBA Date Comparison, and then some...

    Try to avoid using strings to compare dates.... depending on cell formats that can cause unexpected results (which is why I used a variable in my post, set the date controlling year/month/day input and then compared to that). Are you sure when
    rowNum = ActiveCell.Row
    colNum = ActiveCell.Column
    takes place, that the correct cell is active?

+ 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. date comparison
    By mjohn99 in forum Excel General
    Replies: 14
    Last Post: 07-14-2017, 11:06 AM
  2. [SOLVED] Target Date to Completed Date Comparison Percentage output
    By FNG_to_Excel in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-25-2015, 12:32 PM
  3. date comparison
    By jyche14 in forum Excel General
    Replies: 2
    Last Post: 05-09-2011, 03:55 AM
  4. Comparison of Date
    By subhs in forum Excel General
    Replies: 1
    Last Post: 05-16-2009, 01:25 PM
  5. Date comparison
    By Shodan in forum Excel General
    Replies: 6
    Last Post: 02-25-2007, 11:58 AM
  6. Date comparison
    By Darkdrew in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 03-23-2006, 12:25 PM
  7. Date comparison
    By Jonibenj in forum Excel General
    Replies: 6
    Last Post: 10-23-2005, 04:05 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