+ Reply to Thread
Results 1 to 5 of 5

Have VBA read dates as numbers?

  1. #1
    Registered User
    Join Date
    07-30-2009
    Location
    Vancouver, British Columbia
    MS-Off Ver
    Excel 2010
    Posts
    46

    Talking Have VBA read dates as numbers?

    Hi!

    I have a userform that has several textboxes and checkboxes. Some of the textboxes read and display dates from certain cells.
    I have the checkboxes conditionally formatted based on the data in the textboxes. However it doesn't seem to be reading the
    dates as a value. Here's an example of my issue to make it clear for you:

    txtBox 1 = 01Sep2009
    txtBox 2 = 01Oct2009

    What I need is for the checkbox text colour to change from black to red if txtBox1 < txtBox2.

    Here's the code I have in place:

    Please Login or Register  to view this content.
    It doesn't work when there's dates in the txtBox's, but if I use simple numbers (i.e. txtBox1 = 11 and txtBox2 = 22) then it works
    just fine. Maybe VBA isn't reading the dates as numbers, but as text? The formatting of the cells it's reading from are in dates.

    Any ideas

    Cheers,
    Last edited by ilovelagar; 09-23-2009 at 11:00 AM. Reason: Solved

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Have VBA read dates as numbers?

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    07-30-2009
    Location
    Vancouver, British Columbia
    MS-Off Ver
    Excel 2010
    Posts
    46

    Red face Re: Have VBA read dates as numbers?

    Oops, sorry about that; just forgetfulness on my part. I wrote out the post in notepad first and then just copied/pasted over and completely forgot.

    Cheers,

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Have VBA read dates as numbers?

    VBA doesn't recognize ddMMMyyyy as a date string. Input it as something that does, like dd MMM yyyy, and then
    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Registered User
    Join Date
    07-30-2009
    Location
    Vancouver, British Columbia
    MS-Off Ver
    Excel 2010
    Posts
    46

    Talking Re: Have VBA read dates as numbers?

    Quote Originally Posted by shg View Post
    VBA doesn't recognize ddMMMyyyy as a date string. Input it as something that does, like dd MMM yyyy, and then
    Please Login or Register  to view this content.
    Cheers!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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