+ Reply to Thread
Results 1 to 3 of 3

Date value won't work in xl vb code

  1. #1
    Registered User
    Join Date
    06-21-2010
    Location
    Suffolk, England
    MS-Off Ver
    Excel 2003
    Posts
    8

    Date value won't work in xl vb code

    I have been struggling with this for over a week now and just can't understand why I can't get the date section of code to work.

    I'm using a data source and trying to enter a date range

    This code works fine as it uses a predefined date range i.e. WHERE (slotapp.slotdate='20131010'):
    Please Login or Register  to view this content.
    I would like to use a cell in xl that I can enter a date, so to try and get this code to work I am first using a variable instead of a cell, but it doesn't recognise the date in the variable

    All I have done is added the variable: Dim sDate As String sDate = 20131010

    ..And entered it in the code: WHERE (slotapp.slotdate='sDate')

    Please Login or Register  to view this content.
    Does anybody know what I am doing wrong or why it won't work and what it is I need to do to get it to work?

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,946

    Re: Date value won't work in xl vb code

    My VBA is poor at best, so I have no idea if this is relevant here, but excel uses 5-digit numbers for dates, even though it looks like a "real" date. So 10/12/2013 is actually 41559
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    06-21-2010
    Location
    Suffolk, England
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Date value won't work in xl vb code

    Was finally presented with the answer:

    Please Login or Register  to view this content.
    Thank you anyway

+ 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] Work Order tracker date code not working properly
    By Jeff up North in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 02-15-2013, 03:25 PM
  2. [SOLVED] Code for Calendar to work across multiple Date columns?
    By Ninaval in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-01-2013, 06:53 AM
  3. Replies: 2
    Last Post: 05-04-2012, 07:27 AM
  4. code to work on displaying date automatically
    By tweety127 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-15-2008, 12:51 AM

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