+ Reply to Thread
Results 1 to 4 of 4

Checking if date value in cell is between or equal to start and end date

  1. #1
    Registered User
    Join Date
    10-22-2014
    Location
    Melbourne
    MS-Off Ver
    2010
    Posts
    2

    Exclamation Checking if date value in cell is between or equal to start and end date

    Hello,

    I am currently working on a vba code to loop through a list of cells, A6:60, but I have been unable to get my code to validate if the cells in this range are between or equal to the data entered by the user in a textbox. I have found that if do not attempt this, the rest of the code works perfectly fine, as such I have only included the basis that I have been having issues with.

    My current code is as follows:

    If Datetxt ">=" dtStart And Datetxt "<=" dtEnd Then
    'Here I have entered data that will send the data to its separate sheet
    else
    MsgBox "The data has been tranfered to the worksheet 'Summary'."
    End If

    'The cells will continue going up here through code until a blank cell is past and the list is through
    If IsEmpty(ActiveCell.Value) Then
    MsgBox " I'm sorry, there was no job found on that date."
    End If


    ' the value of Datetxt = the activecell.value



    I have been working on this problem for days and have been unable to fix it. And it must be in VBA.
    Any and all assistance on this would be greatly appreciated!

    Sincerely,
    Rebecca

  2. #2
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: Checking if date value in cell is between or equal to start and end date

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    10-22-2014
    Location
    Melbourne
    MS-Off Ver
    2010
    Posts
    2

    Re: Checking if date value in cell is between or equal to start and end date

    I seem to be continually getting an error,

    If ((datetxt >= dtStart) And (datetxt <= dtEnd)) Then
    MsgBox datetxt
    Else
    Msgbox "Testing"

    No matter how I use this equation, I am still getting the same "Testing" message.

  4. #4
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: Checking if date value in cell is between or equal to start and end date

    Put a debug on it, in VBA editor click the little column to the left of the Function or Sub name, that should insert a brown circle. Then do what you normally do but it should stop at the point of running this code, you can then step through it using F8 and monitor the variables (switch on the Locals and Immediates windows) or simply hover over the variable names at each step to see what they're populated with.

+ 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] Data Validation won't accept Start Date and End Date from cell values.
    By SpecialBrew in forum Excel General
    Replies: 12
    Last Post: 03-16-2014, 10:23 PM
  2. Split the equal amount acoss months based on start and end date
    By Ktahilramani in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-07-2014, 11:18 PM
  3. Replies: 5
    Last Post: 09-24-2013, 02:40 PM
  4. Replies: 1
    Last Post: 10-02-2012, 02:42 PM
  5. Return cell value on calendar for all dates between start date & end date
    By mmctague in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-23-2012, 02:11 PM

Tags for this Thread

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