+ Reply to Thread
Results 1 to 6 of 6

Macro to validate date & time period

  1. #1
    Registered User
    Join Date
    04-24-2013
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2007
    Posts
    16

    Macro to validate date & time period

    Hello,

    I would like to have an excel macro where it should validate whether the results falls under a week day or a week end.

    Let me elaborate it for better understanding. I have date(mm/dd/yyyy) & time (hh:mm) AM/PM in colum A & colum B. I want the macro to validate if the date & time in A1 is >= Friday 6:30 PM and the date & time in B1 is <= Monday 5:00 PM then C1 should reflect as weekend else weekday.

    Basically if the date/time period between A1 & B1 falls between Friday 6:30 PM to Monday 5:00 PM then C1 should reflect weekend else weekday. And this validation should continue for all the cells A2 & B2, A3 & C3 and so on till the end of the colum until the cells are filled with date and time.

    Any help is greatly appreciated. Thank you in advance.

    Regards

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,995

    Re: Macro to validate date & time period

    This could be done with a formula. Do you require a macro instead of a formula?
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    04-24-2013
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Macro to validate date & time period

    Hi Jeff

    please provide the formula to get the appropriate results for now. however for a continuous use I would like to have a macro to do this job as I will be having around 25,000 to 30,000 rows to validate in this manner .

    Thank you

  4. #4
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Macro to validate date & time period

    Here is macro version:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    04-24-2013
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Macro to validate date & time period

    Hello

    The above macro is based on only A colum however it should validate basing both A & B colums. If the time period falls under Friday 6:30 PM to Monday 5:00 PM then it should reflect Weekend else weekdays. Please check the attached sample.

    Thank you
    Attached Files Attached Files

  6. #6
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: Macro to validate date & time period

    Quote Originally Posted by mishaq View Post
    Hello

    The above macro is based on only A colum however it should validate basing both A & B colums. If the time period falls under Friday 6:30 PM to Monday 5:00 PM then it should reflect Weekend else weekdays. Please check the attached sample.

    Thank you
    See the attachment and test the macro and let me know if it works as per your requirement.
    Attached Files Attached Files
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

+ 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. Replies: 0
    Last Post: 07-25-2013, 10:03 AM
  2. [SOLVED] Time as an elapsed value, not date and time or period between two date times
    By stephenbooth_uk in forum Excel General
    Replies: 2
    Last Post: 05-31-2013, 12:50 PM
  3. Macro with condition of Period, before run, macro should validate the date and Path of fil
    By caapoorvajain in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-17-2012, 04:11 AM
  4. Validate multiple Date and Time for getting TAT
    By marc5354 in forum Excel General
    Replies: 15
    Last Post: 02-18-2010, 03:18 PM
  5. How can i use a command button to validate date and time
    By kcdonaldson in forum Excel General
    Replies: 0
    Last Post: 12-09-2005, 12:10 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