+ Reply to Thread
Results 1 to 8 of 8

Thread: Find start date of the month

  1. #1
    Valued Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    414

    Find start date of the month

    Hi guys

    How to find start date of the month from the last Date of the month using vba. e.g we have 30.01.2012 (This date given). How can I know from this when the month started.

    Thanks

  2. #2
    Valued Forum Contributor Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens Greece
    MS-Off Ver
    Excel 2003
    Posts
    2,300

    Re: Find start date of the month

    Hi

    You can also do it, using formula.

    Why do you need VBA, for this?
    Regards

    Fotis.

    I am proud that i am Greek.

    Just to know every one.We Greeks, we are nοt proud of our politicians. Υou?

    Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Please,mark your thread [SOLVED] if you received your answer.


    My Avadar picture, is from Athens Acropolis.
    http://www.theacropolismuseum.gr

    http://www.visitgreece.gr/

  3. #3
    Valued Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    414

    Re: Find start date of the month

    Which formula can I use?

    Thanks

  4. #4
    Forum Guru TMShucks's Avatar
    Join Date
    07-15-2010
    Location
    Manchester, England
    MS-Off Ver
    MSO 2003 & 2007
    Posts
    6,234

    Re: Find start date of the month

    I think that, generally speaking, the month starts on the first day of the month ... day 1. What am I missing?

    Sub GetFirstDay()
    
    Dim LastDay As Date
    Dim FirstDay As Date
    
    LastDay = DateValue("31/01/12")
    MsgBox Day(LastDay)
    FirstDay = DateValue("1/" & Month(LastDay) & "/" & Year(LastDay))
    MsgBox Day(FirstDay)
    
    End Sub

    Regards, TMS

  5. #5
    Valued Forum Contributor Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens Greece
    MS-Off Ver
    Excel 2003
    Posts
    2,300

    Re: Find start date of the month

    ..Sorry for the delay..

    First day of the month(your date in A1)>> =DATE(YEAR(A1);MONTH(A1); 1)

    First Workday of the month>> =WORKDAY(DATE(YEAR(A1);MONTH(A1);1)-1;1;Holidays)

    Change the semi-colons, to gomma, if it is necassary.

    Hope to helps you.
    Regards

    Fotis.

    I am proud that i am Greek.

    Just to know every one.We Greeks, we are nοt proud of our politicians. Υou?

    Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Please,mark your thread [SOLVED] if you received your answer.


    My Avadar picture, is from Athens Acropolis.
    http://www.theacropolismuseum.gr

    http://www.visitgreece.gr/

  6. #6
    Valued Forum Contributor marreco's Avatar
    Join Date
    07-02-2011
    Location
    Brasil
    MS-Off Ver
    Excel 2007
    Posts
    497

    Re: Find start date of the month

    Hi TMShucks
    sorry I'm intruding, that I wonder if it were using a cell instead of the line of code ..
    MsgBox Day (lastday)
    , how would the code?

  7. #7
    Forum Guru TMShucks's Avatar
    Join Date
    07-15-2010
    Location
    Manchester, England
    MS-Off Ver
    MSO 2003 & 2007
    Posts
    6,234

    Re: Find start date of the month

    @marreco: You should be opening a new thread and referring back to this one (see below).

    However:

    MsgBox Day(Range("A1"))


    For future reference ...

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.

  8. #8
    Valued Forum Contributor marreco's Avatar
    Join Date
    07-02-2011
    Location
    Brasil
    MS-Off Ver
    Excel 2007
    Posts
    497

    Re: Find start date of the month

    Sorry, thank you for help

+ 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.2.0