+ Reply to Thread
Results 1 to 6 of 6

Defining 6 month dates

  1. #1
    Forum Contributor
    Join Date
    02-24-2010
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2003
    Posts
    195

    Unhappy Defining 6 month dates

    I am useing the below code to imput date variables into filepaths. The problem that I am facing is that one file has a 6 month data range within the filename.
    eg. (sample reports May 11 to Oct 11.xls)

    In the below code I am useing TextBox25 to define the NapsMonth (in this case 10_Oct)
    I then use another case statement to define Naps6Month as the 'NapsMonth - 6'.

    However this is not working for me as, in this instance, NapsMonth - 6 would equal 4
    but my case statement is searching for "04".

    This solution as obviously going to cause more trouble at the start of a new year when the NapsMonth returns to 1 again.

    Would anybody be able to offer a alternative work around for this?




    Please Login or Register  to view this content.
    Last edited by TonyforVBA; 11-29-2011 at 12:23 PM.

  2. #2
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: Defining 6 month dates

    Try changing this line

    Please Login or Register  to view this content.
    To
    Please Login or Register  to view this content.
    Please take time to read the forum rules

  3. #3
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Defining 6 month dates

    a oneliner suffices:

    Please Login or Register  to view this content.



  4. #4
    Forum Contributor
    Join Date
    02-24-2010
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2003
    Posts
    195

    Re: Defining 6 month dates

    Steffan, thanks for the formatting tip. That sorts out the first problem grand.

    Snb, I've included the code above in my AssignFilePaths script but I'm getting
    Run Time Error '424';
    Object required.


    Have I done somthing wrong here?

    Please Login or Register  to view this content.

  5. #5
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Defining 6 month dates

    because both textboxes are being referred to you need this code to be in the userform codemodule (I assume the textboxes to reside in a userform).

  6. #6
    Forum Contributor
    Join Date
    02-24-2010
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2003
    Posts
    195

    Re: Defining 6 month dates

    Ahh I see! Thats perfect, I have the filepath assignment code in a seperate mudule so I've just refferenced the Userform name with the each of the TextBox refferences.

    eg. Userform1.TextBox23.

    Thanks for that. Great help as always!!

+ 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