+ Reply to Thread
Results 1 to 3 of 3

Easy Date Vba

Hybrid View

  1. #1
    Registered User
    Join Date
    01-08-2015
    Location
    Dublin
    MS-Off Ver
    Excel 2010
    Posts
    18

    Easy Date Vba

    Hello, I just wish to get the date to be date - 1 (which works), however I want it to save only dates during the week, here is my code. I tried changing the date to workdate - 1 and it gave me a date in 1899.

    Sub Save_Files()

    Dim xDate As Date
    xDate = WorkDate - 1


    Application.ScreenUpdating = False
    On Error GoTo err_handle

    'Format(xDate, "dd-mm-yyyy")

    'Saving MORE Reports
    'NBCGFDELTAINSTRUMENT
    Workbooks.Open Filename:="y:\Risk\Risk Report\MORE\NBCGFDELTAINSTRUMENT.xls"
    ActiveWorkbook.SaveAs Filename:= _
    "y:\Risk\Risk Report\MORE\NBCGFDELTAINSTRUMENT " & Format(xDate, "dd-mm-yyyy") & ".xls"
    ActiveWorkbook.Close

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,493

    Re: Easy Date Vba

    Posting code between [CODE] [/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

  3. #3
    Registered User
    Join Date
    01-08-2015
    Location
    Dublin
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Easy Date Vba

    Sorry this is the code

    
    Sub Save_Files()
    
    Dim xDate As Date
    xDate = WorkDate - 1
    
    Application.ScreenUpdating = False
    On Error GoTo err_handle
    
    Workbooks.Open Filename:="y:\Risk\Risk Report\MORE\NBCGFDELTAINSTRUMENT.xls"
    ActiveWorkbook.SaveAs Filename:= _
    "y:\Risk\Risk Report\MORE\NBCGFDELTAINSTRUMENT " & Format(xDate, "dd-mm-yyyy") & ".xls"

+ 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. Date test VBA - Very easy
    By dantray02 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-02-2014, 10:32 AM
  2. [SOLVED] Easy way of inputting date
    By bigtiger1 in forum Excel General
    Replies: 6
    Last Post: 03-08-2014, 08:00 AM
  3. [SOLVED] Easy date function help
    By gtaaccord in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-11-2013, 12:16 PM
  4. Should be easy...Auto Date Fill
    By -emma- in forum Excel General
    Replies: 5
    Last Post: 07-15-2006, 07:35 AM
  5. Easy Question - Automate date
    By eholtman in forum Excel General
    Replies: 3
    Last Post: 03-03-2005, 02:57 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