+ Reply to Thread
Results 1 to 11 of 11

Date in vba

  1. #1
    Registered User
    Join Date
    02-10-2017
    Location
    IRAQ
    MS-Off Ver
    2016
    Posts
    37

    Red face Date in vba

    hi all ,

    I have report need to send it every day but it back for the day before so how I can make the date for day before the code that I know it its like this :
    " date - 1 "
    but that will give me (month-day-year)(2-20-2017) I want it to become (day-month-year) 20-2-2017 how I can make it like this ?????

    thanks in advance guys
    Last edited by alaboudy; 02-10-2017 at 10:04 AM.

  2. #2
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Date in vba

    Actually dates in excel are numbers (since 01-01-1900), what you see (dd-mm-yyyy or mm-dd-yyyy) is just a number formatting. Change the number formatting of the cell
    If you are pleased with a member's answer then use the Star icon to rate it.

  3. #3
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: Date in vba

    or try this if your date is in a1

    =TEXT(A1-1,"dd/mm/yyyy")
    Teach me Excel VBA

  4. #4
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: Date in vba

    or VBA version
    Format(Date - 1, "dd/mm/yyyy")

  5. #5
    Registered User
    Join Date
    02-10-2017
    Location
    IRAQ
    MS-Off Ver
    2016
    Posts
    37

    Re: Date in vba

    buran
    thank you for your replay the date that I am asking for not in excel it self it in the Email body and subject thats what I am looking for to change it

    ".subject = " daily report for " & date dd/mmmm/yyyy" but for the day before not for the current day

  6. #6
    Registered User
    Join Date
    02-10-2017
    Location
    IRAQ
    MS-Off Ver
    2016
    Posts
    37

    Re: Date in vba

    thank you Imran the vba code it work
    thanks again man

  7. #7
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,883

    Re: Date in vba

    Just subtract 1 from Date.

    FYI - Date in VBA is equivalent of Today() in Excel.
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    02-10-2017
    Location
    IRAQ
    MS-Off Ver
    2016
    Posts
    37

    Re: Date in vba

    thank you Imran the vba code it work
    thanks again man

  9. #9
    Registered User
    Join Date
    02-10-2017
    Location
    IRAQ
    MS-Off Ver
    2016
    Posts
    37

    Re: Date in vba

    thanks man its work now

  10. #10
    Registered User
    Join Date
    02-10-2017
    Location
    IRAQ
    MS-Off Ver
    2016
    Posts
    37

    Re: Date in vba

    thank you Imran the vba code it work
    thanks again man

  11. #11
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: Date in vba

    Thanks for your feedback and rep.

    Acknowledge the responses you receive, good or bad. If your problem is solved, please say so clearly, and mark your thread as Solved: Click Thread Tools above your first post, select "Mark your thread as Solved"

+ 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] Change Date with Date Picker If Date Less Than 7 Days From Another Date
    By Macfool in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-16-2016, 09:10 AM
  2. Week to date, Month to date, Qtr to date and Year to date
    By Neilesh Kumar in forum Excel General
    Replies: 4
    Last Post: 06-10-2016, 08:53 AM
  3. [SOLVED] Formula to compare date (including month and year) from a listed date to today's date
    By mhewitson15 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-11-2014, 05:31 PM
  4. Counting if data falls on date between Start Date, End Date or Possible End Date
    By JessHasQuestions in forum Hello..Introduce yourself
    Replies: 2
    Last Post: 07-26-2014, 08:01 AM
  5. Replies: 1
    Last Post: 10-02-2012, 02:42 PM
  6. Replies: 1
    Last Post: 09-28-2012, 08:52 AM
  7. Replies: 7
    Last Post: 11-16-2008, 05:48 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