+ Reply to Thread
Results 1 to 8 of 8

Date entry control-condition date in cell J>date in cell H

  1. #1
    Forum Contributor
    Join Date
    01-20-2011
    Location
    liverpool
    MS-Off Ver
    Excel 2016
    Posts
    198

    Date entry control-condition date in cell J>date in cell H

    Dear xls Gurus,
    I have a sheet in which 2 colimns H and J are devoted for date.
    There is a code behind which enables pop up calendar for population of those dates when user press and cell.
    date in column H should be smaller than date in column J.

    example file:


    How I can introduce a new function which will check that condition? If it is not fullfilled lets pop up a message "Error-dateJ should be >dateH"
    Thanks!
    Attached Files Attached Files

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

    Re: Date entry control-condition date in cell J>date in cell H

    Try this.....
    Include the following code for Worksheet_Change Event. To do so, right click on the sheet tab --> View Code --> and paste the following code in the code window.
    Please Login or Register  to view this content.
    Does this help?
    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.

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Date entry control-condition date in cell J>date in cell H

    Another method...

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  4. #4
    Forum Contributor
    Join Date
    01-20-2011
    Location
    liverpool
    MS-Off Ver
    Excel 2016
    Posts
    198

    Re: Date entry control-condition date in cell J>date in cell H

    Dear SKTNEER,
    I just added your code below the code that makes the calendar to pop-up.
    It works!!! Thanks a lot!!!!
    BR,
    Erkamu

  5. #5
    Forum Contributor
    Join Date
    01-20-2011
    Location
    liverpool
    MS-Off Ver
    Excel 2016
    Posts
    198

    Re: Date entry control-condition date in cell J>date in cell H

    Quote Originally Posted by AlphaFrog View Post
    Another method...

    Please Login or Register  to view this content.
    Dear Alphafrog,
    I use your code but it did no work. Anyway-thank you!
    BR,
    Erkamu

  6. #6
    Forum Contributor
    Join Date
    01-20-2011
    Location
    liverpool
    MS-Off Ver
    Excel 2016
    Posts
    198

    Re: Date entry control-condition date in cell J>date in cell H

    Dear friends.
    I did some further test and spotted something that I would like to fix.
    That code:
    Please Login or Register  to view this content.
    does the job but I spotted that whenever I trigger an error msg to apear then the cell format is changed. For example in format cell-->protection tab locked indicator got ticked. Before the error it was not locked. Also the dat format in that cell changes from dd-mmm-yyyy to mm/dd/yyyy.

    How the code should be adjusted so after
    Please Login or Register  to view this content.
    cells are not changing its proporties.

    In general the whole sheet is protected and when lock indicator changes from unlock-to lock that makes imposible next data entry in respective cells.

    BR,
    Erkamu

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

    Re: Date entry control-condition date in cell J>date in cell H

    Instead of using Target.clear use Target.ClearContents so that the formatting will remain intact within the target cell.
    If that takes care of your original question, please mark your thread as solved by selecting Thread Tools --> Mark thread as solved.
    Moreover you may also click on * (star) to Add Reputation to those who have put their time and efforts to help you in this forum. This is another way to say thanks to them.
    Last edited by sktneer; 06-01-2014 at 06:53 AM.

  8. #8
    Forum Contributor
    Join Date
    01-20-2011
    Location
    liverpool
    MS-Off Ver
    Excel 2016
    Posts
    198

    Re: Date entry control-condition date in cell J>date in cell H

    Just did it!

+ 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. Send an Email by cell date in comparison to actual date referencing cell text.
    By greaseebogus in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-15-2014, 10:03 PM
  2. Replies: 3
    Last Post: 02-02-2014, 04:26 AM
  3. Replies: 1
    Last Post: 10-02-2012, 02:42 PM
  4. How to leave Date formula cell blank until date entry??
    By NewbieDateFormatter in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-16-2011, 07:50 AM
  5. Adding date to a cell based upon entry in another cell
    By callpaul in forum Excel General
    Replies: 2
    Last Post: 05-17-2010, 03:34 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